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

Issue 2094463002: Allow trailing commas in function parameter lists (Closed)

Created:
4 years, 6 months ago by jwolfe
Modified:
4 years, 5 months ago
Reviewers:
caitp (gmail), adamk
CC:
v8-reviews_googlegroups.com, Michael Hablich
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Allow trailing commas in function parameter lists Add a flag harmony_trailing_commas_in_parameters that allows trailing commas in function parameter declaration lists and function call parameter lists. Trailing commas are allowed in parenthetical lists like `(a, b, c,)` only if the next token is `=>`, thereby making it an arrow function declaration. Only 1 trailing comma is allowed, not `(a,,)`. A trailing comma must follow a non-rest parameter, so `(,)` and `(...a,)` are still SyntaxErrors. However, a trailing comma is allowed after a spread parameter, e.g. `a(...b,);`. Add parser tests for all of the above. BUG=v8:5051 LOG=y Committed: https://crrev.com/1ac0965542e714d6dd9318c46199704e035f3d9b Cr-Commit-Position: refs/heads/master@{#37355}

Patch Set 1 #

Total comments: 13

Patch Set 2 : forward flag to preparser #

Patch Set 3 : more thorough testing #

Patch Set 4 : update grammar comment for FormalParameters to include trailing commas #

Total comments: 4

Patch Set 5 : add tests with more than 1 parameter #

Total comments: 3

Patch Set 6 : add mjsunit test for arguments.length with trailing commas #

Total comments: 4

Patch Set 7 : rename harmony flag to just trailing_commas, omitting _in_parameters #

Patch Set 8 : add test for function length with trailing commas #

Patch Set 9 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+181 lines, -23 lines) Patch
M src/bootstrapper.cc View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -0 lines 0 comments Download
M src/flag-definitions.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -1 line 0 comments Download
M src/parsing/parser.cc View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -0 lines 0 comments Download
M src/parsing/parser-base.h View 1 2 3 4 5 6 7 8 7 chunks +36 lines, -22 lines 0 comments Download
M test/cctest/test-parsing.cc View 1 2 3 4 5 6 7 8 3 chunks +107 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/trailing-commas-length.js View 1 2 3 4 5 6 7 1 chunk +31 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (5 generated)
jwolfe
My confidence level on this patch could be classified as "WIP", although I don't know ...
4 years, 6 months ago (2016-06-22 18:04:42 UTC) #2
caitp (gmail)
Great work, here's a first round of comments, I'll take another look in a bit ...
4 years, 6 months ago (2016-06-22 18:56:20 UTC) #4
jwolfe
https://codereview.chromium.org/2094463002/diff/1/test/cctest/test-parsing.cc File test/cctest/test-parsing.cc (right): https://codereview.chromium.org/2094463002/diff/1/test/cctest/test-parsing.cc#newcode7824 test/cctest/test-parsing.cc:7824: { "'use strict';", "" }, On 2016/06/22 18:04:41, jwolfe ...
4 years, 6 months ago (2016-06-23 18:43:00 UTC) #5
adamk
Haven't looked at the code yet, but a couple suggestions for tests to add. https://codereview.chromium.org/2094463002/diff/60001/test/cctest/test-parsing.cc ...
4 years, 6 months ago (2016-06-23 22:08:50 UTC) #6
jwolfe
https://codereview.chromium.org/2094463002/diff/60001/test/cctest/test-parsing.cc File test/cctest/test-parsing.cc (right): https://codereview.chromium.org/2094463002/diff/60001/test/cctest/test-parsing.cc#newcode7821 test/cctest/test-parsing.cc:7821: TEST(TrailingCommasInParameters) { On 2016/06/23 22:08:49, adamk wrote: > Please ...
4 years, 5 months ago (2016-06-27 23:28:21 UTC) #7
adamk
Can you add a few mjsunit tests for various kinds of functions that shows '.length' ...
4 years, 5 months ago (2016-06-28 00:39:47 UTC) #8
jwolfe
https://codereview.chromium.org/2094463002/diff/80001/src/parsing/parser-base.h File src/parsing/parser-base.h (left): https://codereview.chromium.org/2094463002/diff/80001/src/parsing/parser-base.h#oldcode3224 src/parsing/parser-base.h:3224: } while (!parameters->has_rest && Check(Token::COMMA)); On 2016/06/28 00:39:47, adamk ...
4 years, 5 months ago (2016-06-28 21:04:16 UTC) #9
adamk
https://codereview.chromium.org/2094463002/diff/80001/src/parsing/parser-base.h File src/parsing/parser-base.h (left): https://codereview.chromium.org/2094463002/diff/80001/src/parsing/parser-base.h#oldcode3224 src/parsing/parser-base.h:3224: } while (!parameters->has_rest && Check(Token::COMMA)); On 2016/06/28 21:04:16, jwolfe ...
4 years, 5 months ago (2016-06-28 21:10:52 UTC) #10
jwolfe
All comments addressed except for the ExpressionClassifier question.
4 years, 5 months ago (2016-06-28 21:50:11 UTC) #11
adamk
lgtm code-wise, thanks! Do you plan to do some performance analysis before landing? Not strictly ...
4 years, 5 months ago (2016-06-28 21:51:53 UTC) #12
jwolfe
On 2016/06/28 21:51:53, adamk wrote: > lgtm code-wise, thanks! Do you plan to do some ...
4 years, 5 months ago (2016-06-29 01:08:50 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094463002/160001
4 years, 5 months ago (2016-06-29 01:09:05 UTC) #16
commit-bot: I haz the power
Committed patchset #9 (id:160001)
4 years, 5 months ago (2016-06-29 01:38:08 UTC) #17
commit-bot: I haz the power
4 years, 5 months ago (2016-06-29 01:39:23 UTC) #19
Message was sent while issue was closed.
Patchset 9 (id:??) landed as
https://crrev.com/1ac0965542e714d6dd9318c46199704e035f3d9b
Cr-Commit-Position: refs/heads/master@{#37355}

Powered by Google App Engine
This is Rietveld 408576698