Implement sloppy-mode block-defined functions (Annex B 3.3)
authorlittledan <littledan@chromium.org>
Mon, 21 Sep 2015 04:30:50 +0000 (21:30 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 21 Sep 2015 04:31:09 +0000 (04:31 +0000)
commite5ff10d7673a723b1b62b1ddfca194265aaff84c
treec801924bd06a8fc3e676c45f9af2a563e6ac9ab0
parent4962bbb1356ba7465f88c8ed74310159750035b9
Implement sloppy-mode block-defined functions (Annex B 3.3)

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}
20 files changed:
src/ast-expression-visitor.cc
src/ast-literal-reindexer.cc
src/ast-numbering.cc
src/ast.h
src/compiler/ast-graph-builder.cc
src/compiler/ast-loop-assignment-analyzer.cc
src/full-codegen/full-codegen.cc
src/hydrogen.cc
src/interpreter/bytecode-generator.cc
src/parser.cc
src/parser.h
src/pattern-rewriter.cc
src/prettyprinter.cc
src/rewriter.cc
src/scopes.cc
src/scopes.h
src/typing-asm.cc
src/typing.cc
test/mjsunit/harmony/block-let-semantics-sloppy.js
test/mjsunit/harmony/block-sloppy-function.js [new file with mode: 0644]