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.1 intention with `arguments` parameter shadowing #815
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
syg
Feb 14, 2017
Member
The related question from the actual Firefox bug is the following.
(function (a = arguments) {
{ function arguments() { } }
print(arguments);
}());Should this program print [object Arguments] or the function? Current spec text says [object Arguments], i.e., Annex B semantics for FIB does not apply. ES2015 says the function, i.e. Annex B semantics does apply.
Edit: for completeness, SpiderMonkey and V8 both print the function, i.e., apply Annex B semantics.
|
The related question from the actual Firefox bug is the following. (function (a = arguments) {
{ function arguments() { } }
print(arguments);
}());Should this program print Edit: for completeness, SpiderMonkey and V8 both print the function, i.e., apply Annex B semantics. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Feb 14, 2017
Member
@syg I agree with your opinion here.
To spell out some more analysis (which you probably already did, but just to verify that my understanding matches yours), looks like adding arguments to parameterNames is done as the strategy for specifying that if you do var arguments in the body of a function, then arguments still refers to the arguments object. On the other hand, the general design rule for arguments is that, apart from this case, it should be easy to override and trigger it not being created (see all the logic for calculating argumentsObjectNeeded; maybe @allenwb has some more context on the design goals for arguments), so it feels to me like Annex B 3.3 should apply.
We could implement this by making two separate Lists, one for the "real" parameterNames which would be referenced in Annex B 3.3, and one for what's used in step 26-27 for determining which var declarations to actually do something in response to. Even without this semantic issue, I think that would've made sense as a helpful editorial change, as step 21 reads and uses the parametersName list before adding arguments, and then 26-27 uses it after, which is unnecessarily confusing.
|
@syg I agree with your opinion here. To spell out some more analysis (which you probably already did, but just to verify that my understanding matches yours), looks like adding We could implement this by making two separate Lists, one for the "real" parameterNames which would be referenced in Annex B 3.3, and one for what's used in step 26-27 for determining which var declarations to actually do something in response to. Even without this semantic issue, I think that would've made sense as a helpful editorial change, as step 21 reads and uses the parametersName list before adding |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Feb 14, 2017
Contributor
(Credit to @anba for discovering this in Firefox's bug 1339123)
Which was only discovered thanks to the test cases added in WebKit/webkit@9dd0775.
Which was only discovered thanks to the test cases added in WebKit/webkit@9dd0775. |
syg commentedFeb 14, 2017
•
edited
(Credit to @anba for discovering this in Firefox's bug 1339123)
Consider the following two programs:
and
According to the current spec text (ES2017), both programs should print
[object Arguments].According to ES2015, the second program prints
undefined.PR #677 from @jswalden resulted in the semantics change, though he confirmed over IRC any semantics changes from the PR were unintended.
What is the intended behavior here? I am of the opinion both programs should print
[object Arguments]. That is, that the current spec is correct, and ES2015 had an inconsistency bug that has since been fixed.For completeness, SpiderMonkey prints
[object Arguments]for both. V8 printsundefinedfor both. I don't have JSC and Chakra handy, but @anba says they both print[object Arguments]for both tests.