Closed
Bug 1431461
Opened 6 years ago
Closed 6 years ago
Function body var scope mistakenly adds non-var bindings that are immediately shadowed
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla60
Tracking | Status | |
---|---|---|
firefox60 | --- | fixed |
People
(Reporter: shu, Assigned: jorendorff)
References
Details
Attachments
(2 files)
1.17 KB,
patch
|
Details | Diff | Splinter Review | |
2.19 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
Something like function f(x,y=x) { let z; } results in the Parser generating a separate body-level var scope due to the crazy semantics of parameter expressions. In the Parser itself, there is just a single body-level Parser::Scope that holds all the declarations to perform redeclaration checks. When it finishes parsing the function, it'll generate the actual VM Scope data. This is where vars all put together, and lets/consts are all put together into different scopes. For functions with parameter expressions, the function body emits two VM Scopes: a FunctionBodyVar and a Lexical. When emitting the FunctionBodyVar, all bindings (including lets/consts) are mistakenly put into it. This has not manifested in observable errors because they are always immediately shadowed by the same-named bindings in the enclosed Lexical. See the double copy of ma,mb in https://github.com/devtools-html/debugger.html/issues/5061#issuecomment-358106778
Reporter | ||
Comment 1•6 years ago
|
||
Assignee | ||
Comment 2•6 years ago
|
||
Test added by jorendorff.
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → jorendorff
Status: NEW → ASSIGNED
Assignee | ||
Updated•6 years ago
|
Attachment #8944106 -
Flags: review+
Updated•6 years ago
|
Blocks: js-devtools
Assignee | ||
Comment 3•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f4646f6adf3c19be833db9509eedde3169571c91
Assignee | ||
Comment 4•6 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/383d026eaeb7d27f2f2d2ea90e19d07d0b562f3b Bug 1431461 - Filter for only var declarations when generating FunctionBodyVar scope data. r=jorendorff.
Comment 5•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/383d026eaeb7
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in
before you can comment on or make changes to this bug.
Description
•