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
TypeError is expected when reassigning to const
during destructuring in for statement
#6390
TypeError is expected when reassigning to const
during destructuring in for statement
#6390
Conversation
EWS run on previous version of this PR (hash 2bc8820) |
2bc8820
to
95134aa
Compare
EWS run on previous version of this PR (hash 95134aa) |
How do we know what's expected though? I would expect a patch like this to resolve a test262 failure; if such a test doesn't exist, then (we should contribute one, and) the commit message should include other engines' behavior / spec text. |
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.
r=me
Hi @rkirsling, thanks for your comments. The bug report https://bugs.webkit.org/show_bug.cgi?id=247432 already contains the problem and the expectation behavior with other engines. Do we need to confirm that in the commit message?
Should we add the test to the original test262 repository or the test262 test cases in WebKit? |
95134aa
to
e5d27c1
Compare
EWS run on current version of this PR (hash e5d27c1) |
β¦g in for statement https://bugs.webkit.org/show_bug.cgi?id=247432 rdar://102064568 Reviewed by Yusuke Suzuki. Running this JavaScript program should throw TypeError. ``` class x { static #y = { x = 0 } = 0 ; } ``` V8 ``` class x { static #y = { x = 0 } = 0 ; } ^ TypeError: Assignment to constant variable. ``` GraalJS ``` TypeError: Assignment to constant "x" ``` To fix this, we should use AssignmentContext::AssignmentExpression to construct destructuring pattern in for...in/of statement. In this case, symbolTablePut will check for read-only variable without ignoring. * JSTests/stress/destructuring-for-in-of.js: Added. (shouldThrow): * Source/JavaScriptCore/parser/Parser.cpp: (JSC::Parser<LexerType>::parseForStatement): Canonical link: https://commits.webkit.org/256580@main
e5d27c1
to
c228e7c
Compare
Committed 256580@main (c228e7c): https://commits.webkit.org/256580@main Reviewed commits have been landed. Closing PR #6390 and removing active labels. |
Ah, I had no idea that there was a bug report; bugzilla is mostly just PR placeholders at this point, so I'm no longer expecting it to contain useful information. π In this case, the bug report doesn't link to the spec, doesn't mention SM's behavior, and doesn't have a representative test262 case, so it would require further investigation before handlingβwe might find that V8 and SM disagree, or that V8 and SM agree but differ from the spec. This information is what we should have in the commit message, in order to justify the correctness of the change. (test262 cases are convenient because "this patch fixes a test262 failure" is usually an adequate justification on its own.)
The former. We regularly sync JSTests/test262 with upstream test262, so we can't modify those test cases directly. |
c228e7c
e5d27c1
π π§ͺ winπ wincairoπ§ͺ ios-wk2π§ͺ gtk-wk2π§ͺ api-iosπ§ͺ api-macπ§ͺ api-gtkπ§ͺ mac-wk1π§ͺ mac-wk2π§ͺ mac-AS-debug-wk2π§ͺ mac-wk2-stress