• adamk's avatar
    [es6] Fix scoping for default parameters in arrow functions · 02e4d21f
    adamk authored
    When eagerly parsing arrow functions, expressions in default
    parameter initializers are parsed in the enclosing scope,
    rather than in the function's scope (since that scope does not
    yet exist). This leads to VariableProxies being added to the
    wrong scope, and scope chains for FunctionLiterals being incorrect.
    
    This patch addresses these problems by adding a subclass of
    AstExpressionVisitor that moves VariableProxies to the proper
    scope and fixes up scope chains of FunctionLiterals.
    
    This is a revert of the revert https://crrev.com/e41614a058426fb6102e4ab2dd4f98997f00c0fc
    with a much-improved (though not yet perfect) Scope::ResetOuterScope
    method which properly fixes not only the outer_scope_ pointer but also
    fixes the inner_scope_ list in the relevant outer_scopes.
    
    More work likely still needs to be done to make this work completely,
    but it's very close to correct.
    
    BUG=v8:4395
    LOG=y
    
    Review URL: https://codereview.chromium.org/1414283002
    
    Cr-Commit-Position: refs/heads/master@{#31435}
    02e4d21f
ast-expression-visitor.cc 9.57 KB