|
|
Description[parser] Relex restriction on reserved words
Some IdentifierNames are only included in the set of FutureReservedWords
for strict mode code. Outside of strict mode, these IdentifierNames may
be used as Identifiers. Notably, this includes their use as
BindingIdentifiers in LexicalBindings.
From ES2015 12.1.1 Static Semantics: Early Errors (Identifiers):
> It is a Syntax Error if this phrase is contained in strict mode code
> and the StringValue of IdentifierName is: "implements", "interface",
> "let", "package", "private", "protected", "public", "static", or
> "yield".
http://www.ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semantics-early-errors
Due to a error in its heuristic for disambiguating the `let` token, V8
does not currently allow any of the strict-mode-only FutureReservedWords
to be used as a BindingIdentifier outside of strict mode.
Update V8's heuristic for disambiguating the `let` keyword to account
for strict mode, enabling these IdentifierNames to be used
BUG=v8:4918
LOG=N
R=adamk@chromium.org
Committed: https://crrev.com/d0c65f93bf950987e6cdefc1a07b7121edb76583
Cr-Commit-Position: refs/heads/master@{#36296}
Patch Set 1 #
Total comments: 7
Patch Set 2 : incorporate review feedback #Patch Set 3 : Restoring 'let let' case (with explanation) #
Messages
Total messages: 25 (9 generated)
adamk@chromium.org changed reviewers: + littledan@chromium.org
lgtm, but +littledan who came up with IsNextLetKeyword() in the first place to confirm this isn't breaking something else...
lgtm lgtm % testing suggestions This isn't new from your patch, so it doesn't have to be fixed here, but I noticed that the errors generated here seem off by one. Although, in the parser's logic, the 'let' is being used in a weird way, the user might expect the strict mode reserved word to be the one that is underlined in the error. d8> 'use strict'; let implements = 1 (d8):1: SyntaxError: Unexpected strict mode reserved word 'use strict'; let implements = 1 ^^^ SyntaxError: Unexpected strict mode reserved word https://codereview.chromium.org/1891453005/diff/1/src/parsing/parser-base.h File src/parsing/parser-base.h (right): https://codereview.chromium.org/1891453005/diff/1/src/parsing/parser-base.h#n... src/parsing/parser-base.h:2774: case Token::LET: // Yes, you can do let let = ... in sloppy mode Actually, this comment reflects a previous misunderstanding that I had. let let = ... is disallowed. This is enforced in ParserBase::ParseAndClassifyIdentifier (search for LetInLexicalBinding). It probably wouldn't change any behavior (beyond how pretty the error messages are) to remove this line. Sorry for leaving this out of date. https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc File test/cctest/test-parsing.cc (right): https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc... test/cctest/test-parsing.cc:2020: V(yield) I believe all of these extra tests would be valid with 'let' as well, due to the static semantics early errors for use of let in a lexical binding. https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc... test/cctest/test-parsing.cc:2054: "for (let " #NAME " of []) {}", For completeness, you can use const for most of these as well, since that has the same lexical binding rules, right?
https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc File test/cctest/test-parsing.cc (right): https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc... test/cctest/test-parsing.cc:2020: V(yield) On 2016/04/20 at 20:59:56, Dan Ehrenberg wrote: > I believe all of these extra tests would be valid with 'let' as well, due to the static semantics early errors for use of let in a lexical binding. Actually, I see you are using 'no let' for your sloppy mode kSuccess tests. In this case, have you verified that there is a kError test for 'let' for all of these cases? For the strict mode error tests, it should not be necessary to use _NO_LET, however
https://codereview.chromium.org/1891453005/diff/1/src/parsing/parser-base.h File src/parsing/parser-base.h (right): https://codereview.chromium.org/1891453005/diff/1/src/parsing/parser-base.h#n... src/parsing/parser-base.h:2774: case Token::LET: // Yes, you can do let let = ... in sloppy mode On 2016/04/20 20:59:56, Dan Ehrenberg wrote: > Actually, this comment reflects a previous misunderstanding that I had. let let > = ... is disallowed. This is enforced in ParserBase::ParseAndClassifyIdentifier > (search for LetInLexicalBinding). It probably wouldn't change any behavior > (beyond how pretty the error messages are) to remove this line. Sorry for > leaving this out of date. No worries; I'll remove this line while I'm at it. https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc File test/cctest/test-parsing.cc (right): https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc... test/cctest/test-parsing.cc:2020: V(yield) On 2016/04/20 21:02:31, Dan Ehrenberg wrote: > On 2016/04/20 at 20:59:56, Dan Ehrenberg wrote: > > I believe all of these extra tests would be valid with 'let' as well, due to > the static semantics early errors for use of let in a lexical binding. > > Actually, I see you are using 'no let' for your sloppy mode kSuccess tests. In > this case, have you verified that there is a kError test for 'let' for all of > these cases? For the strict mode error tests, it should not be necessary to use > _NO_LET, however Sure thing, I'll add tests for both cases. https://codereview.chromium.org/1891453005/diff/1/test/cctest/test-parsing.cc... test/cctest/test-parsing.cc:2054: "for (let " #NAME " of []) {}", On 2016/04/20 20:59:56, Dan Ehrenberg wrote: > For completeness, you can use const for most of these as well, since that has > the same lexical binding rules, right? Acknowledged.
Hello Adam and Dan. I've uploaded a patch that incorporates Dan's feedback.
lgtm
The CQ bit was checked by mike@mikepennisi.com
The patchset sent to the CQ was uploaded after l-g-t-m from adamk@chromium.org Link to the patchset: https://codereview.chromium.org/1891453005/#ps20001 (title: "incorporate review feedback")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1891453005/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1891453005/20001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: v8_win_nosnap_shared_rel_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_nosnap_shared_rel_ng...) v8_win_nosnap_shared_rel_ng_triggered on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_nosnap_shared_rel_ng...)
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1891453005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1891453005/40001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by littledan@chromium.org
lgtm
The patchset sent to the CQ was uploaded after l-g-t-m from adamk@chromium.org Link to the patchset: https://codereview.chromium.org/1891453005/#ps40001 (title: "Restoring 'let let' case (with explanation)")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1891453005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1891453005/40001
Message was sent while issue was closed.
Committed patchset #3 (id:40001)
Message was sent while issue was closed.
Description was changed from ========== [parser] Relex restriction on reserved words Some IdentifierNames are only included in the set of FutureReservedWords for strict mode code. Outside of strict mode, these IdentifierNames may be used as Identifiers. Notably, this includes their use as BindingIdentifiers in LexicalBindings. From ES2015 12.1.1 Static Semantics: Early Errors (Identifiers): > It is a Syntax Error if this phrase is contained in strict mode code > and the StringValue of IdentifierName is: "implements", "interface", > "let", "package", "private", "protected", "public", "static", or > "yield". http://www.ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semant... Due to a error in its heuristic for disambiguating the `let` token, V8 does not currently allow any of the strict-mode-only FutureReservedWords to be used as a BindingIdentifier outside of strict mode. Update V8's heuristic for disambiguating the `let` keyword to account for strict mode, enabling these IdentifierNames to be used BUG=v8:4918 LOG=N R=adamk@chromium.org ========== to ========== [parser] Relex restriction on reserved words Some IdentifierNames are only included in the set of FutureReservedWords for strict mode code. Outside of strict mode, these IdentifierNames may be used as Identifiers. Notably, this includes their use as BindingIdentifiers in LexicalBindings. From ES2015 12.1.1 Static Semantics: Early Errors (Identifiers): > It is a Syntax Error if this phrase is contained in strict mode code > and the StringValue of IdentifierName is: "implements", "interface", > "let", "package", "private", "protected", "public", "static", or > "yield". http://www.ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semant... Due to a error in its heuristic for disambiguating the `let` token, V8 does not currently allow any of the strict-mode-only FutureReservedWords to be used as a BindingIdentifier outside of strict mode. Update V8's heuristic for disambiguating the `let` keyword to account for strict mode, enabling these IdentifierNames to be used BUG=v8:4918 LOG=N R=adamk@chromium.org Committed: https://crrev.com/d0c65f93bf950987e6cdefc1a07b7121edb76583 Cr-Commit-Position: refs/heads/master@{#36296} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/d0c65f93bf950987e6cdefc1a07b7121edb76583 Cr-Commit-Position: refs/heads/master@{#36296}
Message was sent while issue was closed.
On 2016/05/17 21:14:09, commit-bot: I haz the power wrote: > Patchset 3 (id:??) landed as > https://crrev.com/d0c65f93bf950987e6cdefc1a07b7121edb76583 > Cr-Commit-Position: refs/heads/master@{#36296} Great! Thanks Dan and Adam! |