Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAnnex B.3.3 still doesn't actually allow you to redeclare sloppy functions in block #913
Comments
added a commit
to syg/ecma262
that referenced
this issue
May 8, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@bterlson Feedback on the proposed language in that commit? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bakkot
May 23, 2017
Contributor
@syg that commit seems fine to me insofar as we are willing to continue having hypotheticals in the spec, which is Not Great but works ok (and is after all what we're already doing).
|
@syg that commit seems fine to me insofar as we are willing to continue having hypotheticals in the spec, which is Not Great but works ok (and is after all what we're already doing). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Sep 6, 2017
Contributor
I don't think the proposed approach works for switch-statements when duplicate function declarations are present across multiple case-clauses:
function f() {
switch (1) {
case 1:
function fb(){} // B.3.3.1 replaces this |var fb|.
default:
function fb(){} // The hypothetical block also needs to replace this function.
}
print(typeof fb); // Should print "function" per web-reality
}
f();|
I don't think the proposed approach works for switch-statements when duplicate function declarations are present across multiple case-clauses: function f() {
switch (1) {
case 1:
function fb(){} // B.3.3.1 replaces this |var fb|.
default:
function fb(){} // The hypothetical block also needs to replace this function.
}
print(typeof fb); // Should print "function" per web-reality
}
f(); |
syg commentedMay 8, 2017
(Thanks to @anba yet again.)
The conclusion to #320 was that we'd allow multiple same-named functions in block in sloppy mode.
Consider the following program:
On all of SpiderMonkey, V8, JSC, and Chakra, this prints
function g() {2}. That is, all implementations agree that Annex B.3.3 semantics should apply to the inner, redeclaredg.The actual letter of Annex B.3.3, though, all say something like "If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors ..."
The thing is, replacing either
function gabove with an actualvar gactually would produce an Early Error, since the allowance we gave to multiple FIB is specifically tied to their FunctionDeclarations. That is,the following program is an Early Error:
So according to the current spec text, Annex B.3.3 does not apply to
g. This is a spec oversight, since I'm pretty sure we specifically tried to allow this case.