• 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
..
regress Loading commit data...
array-species-constructor-delete.js Loading commit data...
array-species-constructor.js Loading commit data...
array-species-delete.js Loading commit data...
array-species-modified.js Loading commit data...
array-species-parent-constructor.js Loading commit data...
array-species-proto.js Loading commit data...
array-species.js Loading commit data...
arraybuffer-species.js Loading commit data...
atomics.js Loading commit data...
block-conflicts-sloppy.js Loading commit data...
block-const-assign-sloppy.js Loading commit data...
block-eval-var-over-let.js Loading commit data...
block-for-sloppy.js Loading commit data...
block-lazy-compile.js Loading commit data...
block-leave-sloppy.js Loading commit data...
block-let-crankshaft-sloppy.js Loading commit data...
block-let-declaration-sloppy.js Loading commit data...
block-let-semantics-sloppy.js Loading commit data...
block-scoping-sloppy.js Loading commit data...
block-scoping-top-level-sloppy.js Loading commit data...
block-sloppy-function.js Loading commit data...
dataview-accessors.js Loading commit data...
debug-step-destructuring-assignment.js Loading commit data...
debug-step-destructuring-bind.js Loading commit data...
debug-stepin-default-parameters.js Loading commit data...
debug-stepin-proxies.js Loading commit data...
default-parameters-debug.js Loading commit data...
default-parameters-destructuring.js Loading commit data...
default-parameters.js Loading commit data...
destructuring-assignment-lazy.js Loading commit data...
destructuring-assignment.js Loading commit data...
destructuring-parameters-literalcount-nolazy.js Loading commit data...
destructuring-parameters-literalcount.js Loading commit data...
destructuring.js Loading commit data...
do-expressions-control.js Loading commit data...
do-expressions.js Loading commit data...
function-name.js Loading commit data...
function-sent.js Loading commit data...
futex.js Loading commit data...
generators.js Loading commit data...
instanceof-es6.js Loading commit data...
iterator-close.js Loading commit data...
module-linking.js Loading commit data...
module-parsing-eval.js Loading commit data...
module-recompile.js Loading commit data...
module-resolution.js Loading commit data...
modules.js Loading commit data...
object-entries.js Loading commit data...
object-get-own-property-descriptors.js Loading commit data...
object-values.js Loading commit data...
private-symbols.js Loading commit data...
private.js Loading commit data...
promise-species.js Loading commit data...
proxies-accesschecks.js Loading commit data...
proxies-apply.js Loading commit data...
proxies-bind.js Loading commit data...
proxies-construct.js Loading commit data...
proxies-cross-realm-exception.js Loading commit data...
proxies-define-property.js Loading commit data...
proxies-delete-property.js Loading commit data...
proxies-example-membrane.js Loading commit data...
proxies-for.js Loading commit data...
proxies-function.js Loading commit data...
proxies-get-own-property-descriptor.js Loading commit data...
proxies-get-prototype-of.js Loading commit data...
proxies-get.js Loading commit data...
proxies-global-reference.js Loading commit data...
proxies-has-own-property.js Loading commit data...
proxies-has.js Loading commit data...
proxies-hash.js Loading commit data...
proxies-integrity.js Loading commit data...
proxies-is-extensible.js Loading commit data...
proxies-json.js Loading commit data...
proxies-keys.js Loading commit data...
proxies-object-assign.js Loading commit data...
proxies-ownkeys.js Loading commit data...
proxies-prevent-extensions.js Loading commit data...
proxies-property-is-enumerable.js Loading commit data...
proxies-prototype-handler-stackoverflow.js Loading commit data...
proxies-prototype-target-stackoverflow.js Loading commit data...
proxies-revocable.js Loading commit data...
proxies-set-prototype-of.js Loading commit data...
proxies-set.js Loading commit data...
proxies-with-unscopables.js Loading commit data...
proxies-with.js Loading commit data...
proxies.js Loading commit data...
reflect-apply.js Loading commit data...
reflect-construct.js Loading commit data...
reflect-define-property.js Loading commit data...
reflect-get-own-property-descriptor.js Loading commit data...
reflect-get-prototype-of.js Loading commit data...
reflect-own-keys.js Loading commit data...
reflect-prevent-extensions.js Loading commit data...
reflect-set-prototype-of.js Loading commit data...
reflect.js Loading commit data...
regexp-flags.js Loading commit data...
regexp-lookbehind.js Loading commit data...
regexp-sticky.js Loading commit data...
set-prototype-of.js Loading commit data...
sharedarraybuffer.js Loading commit data...
simd.js Loading commit data...
sloppy-implicit-block-function.js Loading commit data...
sloppy-restrictive-block-function.js Loading commit data...
species.js Loading commit data...
string-match.js Loading commit data...
string-replace.js Loading commit data...
string-split.js Loading commit data...
to-length.js Loading commit data...
to-name.js Loading commit data...
to-number.js Loading commit data...
to-primitive.js Loading commit data...
to-string.js Loading commit data...
typedarray-species.js Loading commit data...
unicode-character-ranges.js Loading commit data...
unicode-escapes-in-regexps.js Loading commit data...
unicode-regexp-backrefs.js Loading commit data...
unicode-regexp-ignore-case-noi18n.js Loading commit data...
unicode-regexp-ignore-case.js Loading commit data...
unicode-regexp-last-index.js Loading commit data...
unicode-regexp-property-class.js Loading commit data...
unicode-regexp-restricted-syntax.js Loading commit data...
unicode-regexp-unanchored-advance.js Loading commit data...
unicode-regexp-zero-length.js Loading commit data...