-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: Let all early errors be SyntaxErrors. #1527
Conversation
Nice, I'd love to see the outcome of this in the meeting. I'm somehow neutral do this change (on how it is concluded), and interested to hear more feedback from TC39. |
Ross, could you please copy-paste the table from #691 (comment) to your top post here? Saves people a click :) It’s interesting that these are |
@mathiasbynens My pleasure!
So the status is that JSC has Mainly, it's strange that out of 40 sections' worth of early errors in the spec, only two include early Now, one might question whether it's really worth going back on an earlier decision here, if early error types are mostly "cosmetic" anyway. But as @allenwb pointed out in #691 (comment), it's Edit (5/16): Updated JSC status from late |
It's not strange, it's history.
So the specified error for PutValue has always been ReferenceError. And reporting of early detectable errors has evolved from may be reported as soon as possible to must be an early error. The specification has always been mute about how early errors are reported and whether or not "syntax error" means the same thing as "SyntaxError". It doesn't matter when we're talking at the level of parse time error messages. It really only makes a difference when early errors are reflected back as actual exceptions via |
Thanks for the history, @allenwb. It stops a little early, though: #156, included in ES2016, changed the semantics for PeformEval from
to
Which means that it currently is the case that the type of the early error is in fact reflected back as in the actual exception thrown by As a small aside, it's not quite the case that the types of parse errors at the top level (i.e., not in <!doctype html>
<html>
<head><title>demo</title>
<script>
addEventListener('error', e => { alert(e.error.name); });
</script>
<script>
0++;
</script>
</head> in Firefox ( (Github doesn't allow
if you want.) But that's neither here nor there. |
Possibly an ill-advised changed. The intent in the ES6 text was that a caller of |
I agree. This patch resolves that difficulty with a slightly larger-than-necessary hammer. |
This is now implemented in JSC (as they needed to be turned into early errors regardless). 😄 |
https://bugs.webkit.org/show_bug.cgi?id=197603 Reviewed by Keith Miller. JSTests: * test262/expectations.yaml: Update expectations to reflect new SyntaxErrors. (Ideally, these should all be viewed as passing in the near future.) * stress/async-await-basic.js: * stress/big-int-literals.js: Update tests to reflect new SyntaxErrors. * ChakraCore.yaml: * ChakraCore/test/EH/try6.baseline-jsc: * ChakraCore/test/Error/variousErrors3.baseline-jsc: Added. Update baselines to reflect new SyntaxErrors. Source/JavaScriptCore: Since ES6, expressions like 0++, ++0, 0 = 0, and 0 += 0 are all specified as early errors: https://tc39.github.io/ecma262/#sec-update-expressions-static-semantics-early-errors https://tc39.github.io/ecma262/#sec-assignment-operators-static-semantics-early-errors We currently throw late ReferenceErrors for these -- let's turn them into early SyntaxErrors. (This is based on the expectation that tc39/ecma262#1527 will be accepted; if that doesn't come to pass, we can subsequently introduce early ReferenceError and revise these.) * bytecompiler/NodesCodegen.cpp: (JSC::PostfixNode::emitBytecode): Add an assert for "function call LHS" case. (JSC::PrefixNode::emitBytecode): Add an assert for "function call LHS" case. * parser/ASTBuilder.h: (JSC::ASTBuilder::isLocation): Added. (JSC::ASTBuilder::isAssignmentLocation): Fix misleading parameter name. (JSC::ASTBuilder::isFunctionCall): Added. (JSC::ASTBuilder::makeAssignNode): Add an assert for "function call LHS" case. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::isLocation): Added. (JSC::SyntaxChecker::isAssignmentLocation): Fix incorrect definition and align with ASTBuilder. (JSC::SyntaxChecker::isFunctionCall): Added. * parser/Nodes.h: (JSC::ExpressionNode::isFunctionCall const): Added. Ensure that the parser can check whether an expression node is a function call. * parser/Parser.cpp: (JSC::Parser<LexerType>::isSimpleAssignmentTarget): Added. (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parseUnaryExpression): See below. * parser/Parser.h: Throw SyntaxError whenever an assignment or update expression's target is invalid. Unfortunately, it seems that web compatibility obliges us to exempt the "function call LHS" case in sloppy mode. (tc39/ecma262#257 (comment)) Additional cleanup items: - Make use of `semanticFailIfTrue` for `isMetaProperty` checks, as it's equivalent. - Rename `requiresLExpr` to `hasPrefixUpdateOp` since it's now confusing, and get rid of `modifiesExpr` since it refers to the exact same condition. - Stop setting `lastOperator` near the end -- one case was incorrect and regardless neither is used. LayoutTests: * fast/events/window-onerror4-expected.txt: * ietestcenter/Javascript/11.13.1-1-1-expected.txt: * ietestcenter/Javascript/11.13.1-1-2-expected.txt: * ietestcenter/Javascript/11.13.1-1-3-expected.txt: * ietestcenter/Javascript/11.13.1-1-4-expected.txt: * js/basic-strict-mode-expected.txt: * js/dom/assign-expected.txt: * js/dom/line-column-numbers-expected.txt: * js/dom/line-column-numbers.html: * js/dom/postfix-syntax-expected.txt: * js/dom/prefix-syntax-expected.txt: * js/dom/script-tests/line-column-numbers.js: * js/function-toString-parentheses-expected.txt: * js/parser-syntax-check-expected.txt: * js/parser-xml-close-comment-expected.txt: * js/script-tests/function-toString-parentheses.js: * js/script-tests/parser-syntax-check.js: Update tests & expectations to reflect new SyntaxErrors. * js/script-tests/toString-prefix-postfix-preserve-parens.js: * js/toString-prefix-postfix-preserve-parens-expected.txt: None of the prefix/postfix tests make sense here now that they're all SyntaxErrors; remove them and just leave the typeof tests. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
This reached consensus today at the Berlin meeting. 🎉 Tests Implementations
|
tests landed. Edit: sorry, just noticed the label change. Thanks @ljharb |
ab04c1b
to
a0a9f8e
Compare
(Resolved conflict.) |
a0a9f8e
to
a95e95a
Compare
Implement the spec change from the following TC39 PR: tc39/ecma262#1527 Bug: v8:9326 Change-Id: I9639903b12e7621e323990e2335f00e0313a59c3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643171 Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#62451}
This reverts commit 99fd5b9. Reason for revert: fails presubmit test: https://ci.chromium.org/p/v8/builders/ci/V8%20Presubmit/5238 and a nosnap test https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/34143 Original change's description: > Let all early errors be SyntaxErrors. > > Implement the spec change from the following TC39 PR: > tc39/ecma262#1527 > > Bug: v8:9326 > Change-Id: I9639903b12e7621e323990e2335f00e0313a59c3 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643171 > Reviewed-by: Adam Klein <adamk@chromium.org> > Reviewed-by: Toon Verwaest <verwaest@chromium.org> > Commit-Queue: Adam Klein <adamk@chromium.org> > Cr-Commit-Position: refs/heads/master@{#62451} TBR=adamk@chromium.org,verwaest@chromium.org,rkirsling@gmail.com Change-Id: If63b97725e9737ad5a98800e1194caf8e9c1c43d No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:9326 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682393 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#62452}
This is a reland of 99fd5b9 which includes a missed update to test/test262/test262.status. Implement the spec change from the following TC39 PR: tc39/ecma262#1527 Bug: v8:9326 Change-Id: Ie3aac60db550e90fb648fc30886a05419fa41afe TBR: adamk@chromium.org Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682989 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#62500}
This reverts commit 89d93e3. Reason for revert: Breaks layout tests: https://ci.chromium.org/p/v8/builders/ci/V8-Blink%20Linux%2064/32929 Original change's description: > Reland "Let all early errors be SyntaxErrors." > > This is a reland of 99fd5b9 which includes a missed update to > test/test262/test262.status. > > Implement the spec change from the following TC39 PR: > tc39/ecma262#1527 > > Bug: v8:9326 > Change-Id: Ie3aac60db550e90fb648fc30886a05419fa41afe > TBR: adamk@chromium.org > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682989 > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> > Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> > Cr-Commit-Position: refs/heads/master@{#62500} TBR=adamk@chromium.org,gsathya@chromium.org,verwaest@chromium.org,rkirsling@gmail.com Change-Id: Ia56dcda6780a2b1249749e1e7978b35b5e33fbcf No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:9326 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687678 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#62509}
This is a reland of 89d93e3 Original change's description: > Reland "Let all early errors be SyntaxErrors." > > This is a reland of 99fd5b9 which includes a missed update to > test/test262/test262.status. > > Implement the spec change from the following TC39 PR: > tc39/ecma262#1527 > > Bug: v8:9326 > Change-Id: Ie3aac60db550e90fb648fc30886a05419fa41afe > TBR: adamk@chromium.org > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682989 > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> > Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> > Cr-Commit-Position: refs/heads/master@{#62500} Bug: v8:9326 Change-Id: Ic30280400dfa5b83a4a397888e563eee479446c5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1688271 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Tamer Tas <tmrts@chromium.org> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#62553}
FWIW, this now has three landed implementations. 🎊 |
Merge pull request #6347 from rhuanjl:parseErrorImprovements This PR turns early reference errors into syntax errors per tc39/ecma262#1527 And makes a few other error message improvements including fixing #6339 fix: #6339
Resolves #691.
(This does not handle all concerns discussed in that thread, but it does serve as a solution for the OP.
See #691 (comment) onward for my own reasoning; in hindsight, I should've made a separate issue.)