• littledan's avatar
    Restrict FunctionDeclarations in Statement position · 0e7f095c
    littledan authored
    ES2015 generally bans FunctionDeclarations in positions which expect a Statement,
    as opposed to a StatementListItem, such as a FunctionDeclaration which constitutes
    the body of a for loop. However, Annex B 3.2 and 3.4 make exceptions for labeled
    function declarations and function declarations as the body of an if statement in
    sloppy mode, in the latter case specifying that the semantics are as if the
    function declaration occurred in a block. Chrome has historically permitted
    further extensions, for the body of any flow control construct.
    
    This patch addresses both the syntactic and semantic mismatches between V8 and
    the spec. For the semantic mismatch, function declarations as the body of if
    statements change from unconditionally hoisting in certain cases to acquiring
    the sloppy mode function in block semantics (based on Annex B 3.3). For the
    extra syntax permitted, this patch adds a flag,
    --harmony-restrictive-declarations, which excludes disallowed function declaration
    cases. A new UseCounter, LegacyFunctionDeclaration, is added to count how often
    function declarations occur as the body of other constructs in sloppy mode. With
    this patch, the code generally follows the form of the specification with respect
    to parsing FunctionDeclarations, rather than allowing them in arbitrary Statement
    positions, and makes it more clear where our extensions occur.
    
    BUG=v8:4647
    R=adamk
    LOG=Y
    
    Review URL: https://codereview.chromium.org/1757543003
    
    Cr-Commit-Position: refs/heads/master@{#34470}
    0e7f095c
Name
Last commit
Last update
benchmarks Loading commit data...
build Loading commit data...
docs Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party/binutils Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
Makefile.nacl Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...