Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 29e6343215e955fd6b3b2556789c6ae4172485f1
https://github.com/WebKit/WebKit/commit/29e6343215e955fd6b3b2556789c6ae4172485f1
Author: Sosuke Suzuki <[email protected]>
Date: 2026-10-13 (Tue, 13 Oct 2026)
Changed paths:
A JSTests/stress/labelled-function-declaration-scope.js
M JSTests/test262/expectations-linux.yaml
M JSTests/test262/expectations.yaml
M Source/JavaScriptCore/parser/Parser.cpp
Log Message:
-----------
[JSC] Labelled function declarations should be declared in the enclosing scope
https://bugs.webkit.org/show_bug.cgi?id=327346
Reviewed by Yusuke Suzuki.
In sloppy mode, a labelled function declaration in a statement list declares
its name in the enclosing scope, just like an unlabelled one [1][2]. JSC parsed
it in the same way as `if (x) function f() { }` and wrapped it in an implicit
block, so the function was not hoisted to the top of the enclosing scope.
{ f(); label: function f() { } } // TypeError
The implicit block also hid early errors.
let f; label: function f() { } // No SyntaxError
This patch parses it as a function declaration directly, without the implicit
block.
[1]: https://tc39.es/ecma262/#sec-static-semantics-lexicallydeclarednames
[2]: https://tc39.es/ecma262/#sec-static-semantics-toplevelvardeclarednames
Test: JSTests/stress/labelled-function-declaration-scope.js
* JSTests/stress/labelled-function-declaration-scope.js: Added.
(shouldBe):
(label):
(shouldBe.label):
(label1.label2.label3):
(f):
(label1.label2):
(label1):
(label2):
(i.label):
(switch.case.2.label):
(switch):
(switch.case.0.label):
(catch.label):
(catch):
* JSTests/test262/expectations-linux.yaml:
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseExpressionOrLabelStatement):
(JSC::Parser<LexerType>::parseExpressionStatement):
Canonical link: https://commits.webkit.org/323675@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications