Commit ea29437
Ian Halliday
[MERGE chakra-core#936] Fix numerous issues with Use Before Declaration
Merge pull request chakra-core#936 from ianwjhalliday:fix505
Fixes chakra-core#505 and VSO 5425942
Emit() needs to visit all AST nodes so that various algorithms can
collect data and set info on symbols and such, assign locations etc.
In our implementation of the let/const lexical variable Use Before
Declaration error, we had a call to EmitUseBeforeDeclaration() at the
beginning of Emit() and would exit early if it decided to emit the error
into the bytecode. This would prevent visitation of subtrees in certain
cases, like e.g. issue chakra-core#505. It would do this for assignments, i.e.
stores. Detection for Use Before Declaration for loads (and typeof)
are done in EmitPropLoad and EmitPropTypeof.
This fix pushes Use Before Declaration detection for stores down into
EmitPropStore and fixes up where we clear the `needsDeclaration` flag on
symbols that we weren't doing exactly right for EmitPropStore to work
this way.
Summary of changes
- Tweak parse tree tracing to note deferred funcs
- Change EmitPropStore to emit static UseBeforeDecl
- Consolidate Emit() of knop[Var|Let|Const]Decl
- Reduce code duplication in TrackMemberNodesInObjectForIntConstants
- Add missing EmitUseBeforeDeclaration in EmitReference for knopCall
- Remove EmitUseBeforeDeclaration for knopVarDecl case in Emit()
- Remove redundant parameter fLoadUndef from
EmitUseBeforeDeclarationRuntimeError(). Use the presence of the
location parameter to indicate that a LdUndef is needed instead.
- Remove fAcquire param from EmitUseBeforeDeclaration
- Remove pnodeNeedUndef parameter from EmitUseBeforeDeclaration
- Remove always true fAssignRegs parameter from EmitApplyCall.
- Removed call to EmitUseBeforeDeclaration in
EmitCallTargetNoEvalComponents. This was the only remaining call
that used pnodeNeedUndef, hence ability to remove that parameter
from EmitUseBeforeDeclaration.
- Added three test cases to unittests3 files changed
Lines changed: 161 additions & 162 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12915 | 12915 | | |
12916 | 12916 | | |
12917 | 12917 | | |
| 12918 | + | |
| 12919 | + | |
| 12920 | + | |
| 12921 | + | |
| 12922 | + | |
| 12923 | + | |
12918 | 12924 | | |
12919 | 12925 | | |
12920 | 12926 | | |
| |||
0 commit comments