Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Issue 1941823003: Properly disallow 'yield' in class expressions and arrow parameters (Closed)

Created:
4 years, 7 months ago by adamk
Modified:
4 years, 7 months ago
CC:
v8-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Properly disallow 'yield' in class expressions and arrow parameters Yield expressions are not allowed in formal parameter initializers of generators, but we weren't properly catching the case where the yield expression appeared in the 'extends' clause of a class expression. They also aren't allowed in arrow functions, which we were failing to catch due to not looking at the obscurely-named "FormalParameterInitializerError" bit of ExpressionClassifier. This patch passes along an ExpressionClassifier when parsing class expressions and accumulates the proper error for that case. For the arrow function case, the fix is simply to check for the "formal parameter initializer" error once we know we've parsed an arrow function. The error message used for this has also been made specific to yield expressions. Tests are added both for the error case and the non-error cases (where yield is used in such a position inside the class body). BUG=v8:4966, v8:4968, v8:4974 LOG=n Committed: https://crrev.com/9e9abcfff46084f60ad83acb26f56f13ac04347f Cr-Commit-Position: refs/heads/master@{#35957}

Patch Set 1 #

Patch Set 2 : Add a few more tests #

Patch Set 3 : Rebased #

Patch Set 4 : Fix all yield things #

Patch Set 5 : Better error message for yield in parameter #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+83 lines, -50 lines) Patch
M src/messages.h View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M src/parsing/parser.h View 2 chunks +4 lines, -3 lines 0 comments Download
M src/parsing/parser.cc View 5 chunks +17 lines, -13 lines 0 comments Download
M src/parsing/parser-base.h View 1 2 3 4 4 chunks +10 lines, -11 lines 2 comments Download
M src/parsing/preparser.h View 2 chunks +4 lines, -2 lines 0 comments Download
M src/parsing/preparser.cc View 4 chunks +16 lines, -12 lines 0 comments Download
M test/cctest/test-parsing.cc View 1 2 3 5 chunks +20 lines, -1 line 0 comments Download
A + test/message/yield-in-arrow-param.js View 1 2 3 4 1 chunk +1 line, -3 lines 0 comments Download
A test/message/yield-in-arrow-param.out View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
A + test/message/yield-in-generator-param.js View 1 2 3 4 1 chunk +1 line, -3 lines 0 comments Download
A test/message/yield-in-generator-param.out View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (7 generated)
adamk
4 years, 7 months ago (2016-05-02 20:46:22 UTC) #2
adamk
Now this fixes all the things (with a TODO to fix the naming).
4 years, 7 months ago (2016-05-02 22:41:08 UTC) #5
Dan Ehrenberg
lgtm https://codereview.chromium.org/1941823003/diff/80001/src/parsing/parser-base.h File src/parsing/parser-base.h (right): https://codereview.chromium.org/1941823003/diff/80001/src/parsing/parser-base.h#newcode1989 src/parsing/parser-base.h:1989: // "YieldExpression", which is its only use. You ...
4 years, 7 months ago (2016-05-02 23:11:43 UTC) #7
adamk
https://codereview.chromium.org/1941823003/diff/80001/src/parsing/parser-base.h File src/parsing/parser-base.h (right): https://codereview.chromium.org/1941823003/diff/80001/src/parsing/parser-base.h#newcode1989 src/parsing/parser-base.h:1989: // "YieldExpression", which is its only use. On 2016/05/02 ...
4 years, 7 months ago (2016-05-02 23:14:18 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1941823003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1941823003/80001
4 years, 7 months ago (2016-05-02 23:14:28 UTC) #10
commit-bot: I haz the power
Committed patchset #5 (id:80001)
4 years, 7 months ago (2016-05-03 01:55:37 UTC) #12
commit-bot: I haz the power
4 years, 7 months ago (2016-05-03 01:57:54 UTC) #14
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/9e9abcfff46084f60ad83acb26f56f13ac04347f
Cr-Commit-Position: refs/heads/master@{#35957}

Powered by Google App Engine
This is Rietveld 408576698