Skip to content

Conversation

@rkirsling
Copy link
Member

@rkirsling rkirsling commented Apr 22, 2025

d8f1247

[JSC] Align sloppy mode `f() = 1` behavior with other engines
https://bugs.webkit.org/show_bug.cgi?id=291882

Reviewed by Yusuke Suzuki.

In tc39/ecma262#3568, we'll finally be specifying the web reality that `f() = 1` is not an early error in sloppy mode.
JSC's behavior on this was mostly aligned with SM/V8's back in https://commits.webkit.org/212076@main,
but there is one outstanding discrepancy to resolve: SM/V8 both call the function before throwing a ReferenceError.

This patch resolves said discrepancy, which applies to not only =, but also += and kin (excluding logical assignment),
++ / --, and for-in/of.

* JSTests/ChakraCore/test/Function/call1.baseline-jsc:
* JSTests/ChakraCore/test/LetConst/tdz1.baseline-jsc:
* JSTests/stress/sloppy-mode-function-call-assignment-targets.js: Added.
* LayoutTests/js/modify-non-references-expected.txt:
* LayoutTests/js/parser-syntax-check-expected.txt:
* LayoutTests/js/script-tests/modify-non-references.js:
* LayoutTests/svg/dom/SVGTransformList-anim-read-only-expected.txt:
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::PostfixNode::emitBytecode):
(JSC::PrefixNode::emitBytecode):
(JSC::AssignErrorNode::emitBytecode):
(JSC::ForInNode::emitBytecode):
(JSC::ForOfNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::makeAssignNode):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::AssignErrorNode::AssignErrorNode):
* Source/JavaScriptCore/parser/Nodes.h:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::isSimpleAssignmentTarget):

Canonical link: https://commits.webkit.org/293996@main

637e395

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@rkirsling rkirsling requested a review from a team as a code owner April 22, 2025 07:34
@rkirsling rkirsling self-assigned this Apr 22, 2025
@rkirsling rkirsling added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Apr 22, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 22, 2025
@rkirsling rkirsling removed the merging-blocked Applied to prevent a change from being merged label Apr 23, 2025
@rkirsling rkirsling force-pushed the eng/JSC-Align-sloppy-mode-f-1-behavior-with-other-engines branch from 97b75ed to 46e2312 Compare April 23, 2025 01:49
@rkirsling rkirsling added the merge-queue Applied to send a pull request to merge-queue label Apr 23, 2025
@webkit-ews-buildbot webkit-ews-buildbot added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels Apr 23, 2025
@rkirsling rkirsling removed the merging-blocked Applied to prevent a change from being merged label Apr 23, 2025
@rkirsling rkirsling force-pushed the eng/JSC-Align-sloppy-mode-f-1-behavior-with-other-engines branch from 46e2312 to 637e395 Compare April 23, 2025 04:23
@rkirsling rkirsling added the merge-queue Applied to send a pull request to merge-queue label Apr 23, 2025
https://bugs.webkit.org/show_bug.cgi?id=291882

Reviewed by Yusuke Suzuki.

In tc39/ecma262#3568, we'll finally be specifying the web reality that `f() = 1` is not an early error in sloppy mode.
JSC's behavior on this was mostly aligned with SM/V8's back in https://commits.webkit.org/212076@main,
but there is one outstanding discrepancy to resolve: SM/V8 both call the function before throwing a ReferenceError.

This patch resolves said discrepancy, which applies to not only =, but also += and kin (excluding logical assignment),
++ / --, and for-in/of.

* JSTests/ChakraCore/test/Function/call1.baseline-jsc:
* JSTests/ChakraCore/test/LetConst/tdz1.baseline-jsc:
* JSTests/stress/sloppy-mode-function-call-assignment-targets.js: Added.
* LayoutTests/js/modify-non-references-expected.txt:
* LayoutTests/js/parser-syntax-check-expected.txt:
* LayoutTests/js/script-tests/modify-non-references.js:
* LayoutTests/svg/dom/SVGTransformList-anim-read-only-expected.txt:
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::PostfixNode::emitBytecode):
(JSC::PrefixNode::emitBytecode):
(JSC::AssignErrorNode::emitBytecode):
(JSC::ForInNode::emitBytecode):
(JSC::ForOfNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::makeAssignNode):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::AssignErrorNode::AssignErrorNode):
* Source/JavaScriptCore/parser/Nodes.h:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::isSimpleAssignmentTarget):

Canonical link: https://commits.webkit.org/293996@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/JSC-Align-sloppy-mode-f-1-behavior-with-other-engines branch from 637e395 to d8f1247 Compare April 23, 2025 05:19
@webkit-commit-queue
Copy link
Collaborator

Committed 293996@main (d8f1247): https://commits.webkit.org/293996@main

Reviewed commits have been landed. Closing PR #44364 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit d8f1247 into WebKit:main Apr 23, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Apr 23, 2025
@rkirsling rkirsling deleted the eng/JSC-Align-sloppy-mode-f-1-behavior-with-other-engines branch April 23, 2025 05:59
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants