Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MERGE #936] Fix numerous issues with Use Before Declaration
Merge pull request #936 from ianwjhalliday:fix505 Fixes #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 #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 unittests
- Loading branch information