Commit 38a3e074 authored by Daniel Ehrenberg's avatar Daniel Ehrenberg Committed by Commit Bot

[parser] Allow multiple labels for function declarations

In sloppy mode, allow multiply labelled function declarations, such as

a: b: function c() {}

Such a form is allowed by the specification, as well as ChakraCore,
SpiderMonkey and JSC (though ChakraCore because it doesn't enforce
any lexical label restrictions.)

Thanks to Andre Bargull for adding the test262 test which caught the bug.

Change-Id: I2d3f172830c2e63252f00afa03177a7d17d79a27
Reviewed-on: https://chromium-review.googlesource.com/527639Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Daniel Ehrenberg <littledan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45802}
parent 2a20ded9
......@@ -5148,7 +5148,7 @@ ParserBase<Impl>::ParseExpressionOrLabelledStatement(
allow_function == kAllowLabelledFunctionStatement) {
return ParseFunctionDeclaration(ok);
}
return ParseStatement(labels, ok);
return ParseStatement(labels, allow_function, ok);
}
// If we have an extension, we allow a native function declaration.
......
......@@ -8703,6 +8703,7 @@ TEST(FunctionDeclarationError) {
"label: function f() { }",
"label: if (true) function f() { }",
"label: if (true) {} else function f() { }",
"label: label2: function f() { }",
NULL
};
// clang-format on
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment