• littledan's avatar
    Implement sloppy-mode block-defined functions (Annex B 3.3) · e5ff10d7
    littledan authored
    ES2015 specifies very particular semantics for functions defined in blocks.
    In strict mode, it is simply a lexical binding scoped to that block. In sloppy
    mode, in addition to that lexical binding, there is a var-style binding in
    the outer scope, which is overwritten with the local binding when the function
    declaration is evaluated, *as long as* introducing ths var binding would not
    create a var/let conflict in the outer scope.
    
    This patch implements the semantics by introducing a DelegateStatement, which
    is initially filled in with the EmptyStatement and overwritten with the
    assignment when the scope is closed out and it can be checked that there is
    no conflict.
    
    This patch is tested with a new mjsunit test, and I tried staging it and running
    test262, finding that the tests that we have disabled due to lack of Annex B
    support now pass.
    
    R=adamk,rossberg
    LOG=Y
    BUG=v8:4285
    
    Review URL: https://codereview.chromium.org/1332873003
    
    Cr-Commit-Position: refs/heads/master@{#30842}
    e5ff10d7
prettyprinter.cc 38.8 KB