Clarification needed on 10.2.1.1.3 SetMutableBinding on a Declarative Environment Record

Mark S. Miller erights at google.com
Sat Jun 5 21:41:11 PDT 2010


On SpiderMonkey, WebKit, and V8 and, I see

var bar = function foo(f) { if (f) {foo = f; foo();} else {print(33);} };
bar(function(){print(44);});
33


which is the behavior I would normally have expected for non-strict code.
The reason the assignment to foo correctly doesn't take is that a named
FunctionExpression brings its name into scope with CreateImmutableBinding
and InitializeImmutableBinding (See the 2nd FunctionExpression production
semantics at the top of chapter 13). For strict mode code I would expect the
failed assignment to fail with a thrown error, but I would normally not have
been surprised by the silent error for non-strict code. That is, until
rereading the following text from 10.2.1.1.3 SetMutableBinding(N,V,S):

[...] If the binding is an immutable binding, a
TypeError is always thrown. The S argument is ignored
because strict mode does not change the meaning of
setting bindings in declarative environment records.


Am I misunderstanding something, or 2) was this the intended spec, or 3) are
these three browsers all non-conformant in the same manner? If the 3rd, I'll
file bugs on this. If the 2nd, should we add a correction to the ES5 errata?

-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100605/8318590e/attachment-0001.html>


More information about the es-discuss mailing list