Phabricator will be unavailable due to database maintenance from 14:00 UTC until 18:00 UTC on Saturday, October 13, 2018.
Bugzilla will remain up during this time. All users have been logged out of Bugzilla

Hoisted block-level function named "arguments" not initialized with undefined per B.3.3.1

NEW
Unassigned

Status

()

P3
normal
2 years ago
a year ago

People

(Reporter: anba, Unassigned)

Tracking

({triage-deferred})

Trunk
triage-deferred
Points:
---

Firefox Tracking Flags

(firefox54 affected)

Details

Attachments

(1 obsolete attachment)

(Reporter)

Description

2 years ago
Test case:
---
(function(a = (print(arguments))) {
  print(arguments);
  { function arguments() {} }
  print(arguments);
})();
---

Expected output:
[object Arguments]
undefined
function arguments() {}

Actual output:
[object Arguments]
[object Arguments]
function arguments() {}


Spec
https://tc39.github.io/ecma262/#sec-web-compat-functiondeclarationinstantiation initializes the block functions which apply for B.3.3.1 with |undefined| in step 1.a.ii.2 if their names aren't included in the |instantiatedVarNames| list.

Comment 1

2 years ago
Recapping some IRC conversation below.

Per current spec text of Annex B that uses |parameterList| to test if Annex B behavior should apply, when a function has |argumentsObjectNeede = true|, Annex B behavior would *not* apply to functions named "arguments".

However, Waldo says this was an unintended normative change from his editorial PR https://github.com/tc39/ecma262/pull/677

I'll go ahead and fix it according to the ES2015 behavior (anba's test case above). Waldo, could you file an upstream PR?
Flags: needinfo?(jwalden+bmo)

Comment 2

2 years ago
Created attachment 8836916 [details] [diff] [review]
Fix 'arguments' handling in parameter expressions when there is also a var binding of 'arguments'.

Turns out our in-tree test was wrong. The bug is that if parameter exprs needed
the arguments object and didn't have a formal named 'parameter', we weren't
treating var bindings of 'arguments' like
regular var bindings.
Attachment #8836916 - Flags: review?(jwalden+bmo)

Comment 3

2 years ago
Comment on attachment 8836916 [details] [diff] [review]
Fix 'arguments' handling in parameter expressions when there is also a var binding of 'arguments'.

I'm not sure what the intended semantics are anymore. Retracting patch.
Attachment #8836916 - Attachment is obsolete: true
Flags: needinfo?(jwalden+bmo)
Attachment #8836916 - Flags: review?(jwalden+bmo)

Comment 5

2 years ago
On test262:

test/annexB/language/function-code/block-decl-func-skip-arguments.js
Keywords: triage-deferred
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.