Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9f543645c49ec94a977a41cfdbadc4ce4298ea2f
https://github.com/WebKit/WebKit/commit/9f543645c49ec94a977a41cfdbadc4ce4298ea2f
Author: Sosuke Suzuki <[email protected]>
Date: 2026-10-13 (Tue, 13 Oct 2026)
Changed paths:
A
JSTests/stress/use-strict-directive-reserved-word-as-parameter-or-function-name.js
M JSTests/test262/expectations-linux.yaml
M JSTests/test262/expectations.yaml
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
Log Message:
-----------
[JSC] Strict mode reserved words should be rejected as parameter and function
names by `"use strict"` directive
https://bugs.webkit.org/show_bug.cgi?id=327337
Reviewed by Yusuke Suzuki.
When a function body has a "use strict" directive, its parameters and its
name are strict mode code too. So the following should be SyntaxErrors[1]:
function foo(implements) { "use strict"; }
function static() { "use strict"; }
The parameters and the name are lexed in sloppy mode, where these words are
plain identifiers, and the check done when the directive is found only knew
about `eval`, `arguments`, duplicate parameters and a function named `yield`.
The parameter case threw at the first call, when the function was reparsed
in strict mode; the function name case was never rejected.
This patch records the strict mode reserved words in the same check.
[1]: https://tc39.es/ecma262/#sec-identifiers-static-semantics-early-errors
Test:
JSTests/stress/use-strict-directive-reserved-word-as-parameter-or-function-name.js
*
JSTests/stress/use-strict-directive-reserved-word-as-parameter-or-function-name.js:
Added.
(shouldThrowSyntaxError):
(shouldNotThrow):
(const.word.of.words.word.codePointAt.0.toString):
(const.word.of.words.escaped.shouldThrowSyntaxError.f):
(const.word.of.words.escaped):
(const.word.of.words.escaped.):
* JSTests/test262/expectations-linux.yaml:
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionInfo):
* Source/JavaScriptCore/parser/Parser.h:
(JSC::isStrictModeReservedWord):
(JSC::Scope::declareParameter):
Canonical link: https://commits.webkit.org/323677@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications