-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JSC] Top-level function declarations should be lexical in module code #19207
Merged
webkit-commit-queue
merged 1 commit into
WebKit:main
from
shvaikalesh:eng/JSC-Top-level-function-declarations-should-be-lexical-in-module-code
Oct 18, 2023
Merged
[JSC] Top-level function declarations should be lexical in module code #19207
webkit-commit-queue
merged 1 commit into
WebKit:main
from
shvaikalesh:eng/JSC-Top-level-function-declarations-should-be-lexical-in-module-code
Oct 18, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shvaikalesh
added
the
JavaScriptCore
For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
label
Oct 18, 2023
EWS run on previous version of this PR (hash a0cfa03) |
rkirsling
approved these changes
Oct 18, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! r=me
shvaikalesh
force-pushed
the
eng/JSC-Top-level-function-declarations-should-be-lexical-in-module-code
branch
from
October 18, 2023 20:25
a0cfa03
to
fdc9b00
Compare
Thank you Ross! Much appreciated π |
shvaikalesh
added
the
unsafe-merge-queue
Applied to send a pull request to merge-queue, but skip building and testing
label
Oct 18, 2023
https://bugs.webkit.org/show_bug.cgi?id=263269 <rdar://problem/117086061> Reviewed by Ross Kirsling. The spec has at least 8 occurrences of > It is a Syntax Error if the LexicallyDeclaredNames of X contains any duplicate entries. early error rules that preclude duplicate lexical declarations. For backwards-compatibility, LexicallyDeclaredNames [1] skips top-level function declarations inside `ScriptBody : StatementList` by invoking TopLevelLexicallyDeclaredNames [2], which returns an empty list for them [3]. However, the semantics of LexicallyDeclaredNames is entirely different for `ModuleItem` (also please see note WebKit#1). The fact that top-level function declarations are lexical in module code is also evident during binding initialization [4]. This change makes top-level function declarations in module code behave like `let` rather than `var`, introducing early errors that come with it, like disallowing duplicates with `var` and `function`. Since inside declareFunction() we can't rely neither on `m_scriptMode` (which is always `Module`, even for nested functions that absolutely should not throw SyntaxError for duplicate declarations), nor on `m_parseMode` (it's already the parse mode of the declared function itself), this change introduces isModuleCode() [5], refactoring parse mode handling in Scope. Also, this patch aligns declareFunctionAsLet() with declareVariable(), called for `let` declarations, by adding `m_declaredVariables` check, which may fail only in module code. Removes now incorrect (for module code only) ASSERT that isn't particularly useful given how simple declareFunction() now is. Aligns JSC with V8 and SpiderMonkey. [1]: https://tc39.es/ecma262/#sec-static-semantics-lexicallydeclarednames [2]: https://tc39.es/ecma262/#sec-static-semantics-toplevellexicallydeclarednames [3]: https://tc39.es/ecma262/#prod-HoistableDeclaration [4]: https://tc39.es/ecma262/#sec-source-text-module-record-initialize-environment (step 24.iii) [5]: https://tc39.es/ecma262/#sec-types-of-source-code * JSTests/modules/async-function-export.js: Moved to JSTests/stress/modules-syntax-error.js. * JSTests/stress/modules-syntax-error.js: * JSTests/test262/expectations.yaml: Mark 8 tests as passing. * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): * Source/JavaScriptCore/parser/Parser.cpp: (JSC::Parser<LexerType>::Parser): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseMemberExpression): * Source/JavaScriptCore/parser/Parser.h: (JSC::Scope::setSourceParseMode): (JSC::Scope::isGlobalCode const): (JSC::Scope::isModuleCode const): (JSC::Scope::declareFunctionAsLet): (JSC::Scope::setIsGlobalCode): (JSC::Scope::setIsModuleCode): (JSC::Parser::declareFunction): (JSC::Scope::setIsGlobalCodeScope): Deleted. (JSC::Scope::isGlobalCodeScope const): Deleted. Canonical link: https://commits.webkit.org/269485@main
webkit-commit-queue
force-pushed
the
eng/JSC-Top-level-function-declarations-should-be-lexical-in-module-code
branch
from
October 18, 2023 20:30
fdc9b00
to
2838f14
Compare
Committed 269485@main (2838f14): https://commits.webkit.org/269485@main Reviewed commits have been landed. Closing PR #19207 and removing active labels. |
webkit-commit-queue
removed
the
unsafe-merge-queue
Applied to send a pull request to merge-queue, but skip building and testing
label
Oct 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
JavaScriptCore
For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
skip-ews
Applied to prevent a change from being run on EWS
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
2838f14
fdc9b00
π§ͺ styleπ iosπ macπ wpeπ wincairoπ ios-simπ mac-AS-debugπ§ͺ wpe-wk2π§ͺ webkitperlπ§ͺ ios-wk2π§ͺ api-macπ gtkπ§ͺ ios-wk2-wptπ§ͺ mac-wk1π§ͺ gtk-wk2π π§ͺ jscπ§ͺ api-iosπ§ͺ mac-wk2π§ͺ api-gtkπ π§ͺ jsc-arm64π tvπ§ͺ mac-AS-debug-wk2π jsc-armv7π tv-simπ§ͺ mac-wk2-stressπ§ͺ jsc-armv7-testsπ watchπ jsc-mipsπ watch-simπ§ͺ jsc-mips-tests