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

Issue 987203003: [parser] parse arrow function only if no linefeed before => (Closed)

Created:
5 years, 9 months ago by caitp (gmail)
Modified:
5 years, 9 months ago
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[parser] parse arrow function only if no linefeed before => BUG=v8:3954 LOG=N R=arv@chromium.org Committed: https://crrev.com/f950ddf581a29c6aac421a0f2fb7cbda783c217e Cr-Commit-Position: refs/heads/master@{#27122}

Patch Set 1 #

Total comments: 3

Patch Set 2 : Remove extra newline between functions #

Unified diffs Side-by-side diffs Delta from patch set Stats (+35 lines, -1 line) Patch
M src/preparser.h View 1 3 chunks +17 lines, -1 line 0 comments Download
M test/cctest/test-parsing.cc View 1 chunk +18 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (2 generated)
caitp (gmail)
PTAL --- much tinier fixup for arrow fns this time =) I'm not totally sure ...
5 years, 9 months ago (2015-03-10 17:22:25 UTC) #1
arv (Not doing code reviews)
LGTM https://codereview.chromium.org/987203003/diff/1/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/987203003/diff/1/src/preparser.h#newcode1683 src/preparser.h:1683: too many new lines https://codereview.chromium.org/987203003/diff/1/src/preparser.h#newcode1683 src/preparser.h:1683: too many ...
5 years, 9 months ago (2015-03-10 17:39:55 UTC) #2
caitp (gmail)
https://codereview.chromium.org/987203003/diff/1/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/987203003/diff/1/src/preparser.h#newcode1683 src/preparser.h:1683: On 2015/03/10 17:39:55, arv wrote: > too many new ...
5 years, 9 months ago (2015-03-10 17:41:55 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/987203003/20001
5 years, 9 months ago (2015-03-10 18:59:55 UTC) #6
commit-bot: I haz the power
Committed patchset #2 (id:20001)
5 years, 9 months ago (2015-03-10 19:24:54 UTC) #7
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/f950ddf581a29c6aac421a0f2fb7cbda783c217e Cr-Commit-Position: refs/heads/master@{#27122}
5 years, 9 months ago (2015-03-10 19:25:13 UTC) #8
marja
I'm confused! I always thought that the rule is "a semicolon is inserted *only* if ...
5 years, 9 months ago (2015-03-10 19:29:44 UTC) #9
caitp (gmail)
On 2015/03/10 19:29:44, marja wrote: > I'm confused! I always thought that the rule is ...
5 years, 9 months ago (2015-03-10 19:36:19 UTC) #10
arv (Not doing code reviews)
5 years, 9 months ago (2015-03-10 19:43:24 UTC) #11
Message was sent while issue was closed.
On 2015/03/10 19:36:19, caitp wrote:
> On 2015/03/10 19:29:44, marja wrote:
> > I'm confused! I always thought that the rule is "a semicolon is inserted
> *only*
> > if it's a syntax error without the semicolon".
> > 
> > Is this no longer true? What's going on here? Is there an additional
> restriction
> > that there cannot be a line feed between params and arrow, independent of
ASI?
> 
> From
> `https://people.mozilla.org/~jorendorff/es6-draft.html#sec-grammar-notation`
> 
> ```
> If the phrase “[no LineTerminator here]” appears in the right-hand side of a
> production of the syntactic grammar, it indicates that the production is a
> restricted production: it may not be used if a LineTerminator occurs in the
> input stream at the indicated position. For example, the production:
> 
> ThrowStatement :
> throw [no LineTerminator here] Expression ;
> indicates that the production may not be used if a LineTerminator occurs in
the
> script between the throw token and the Expression.
> ```
> 
> Since the arrow function production requires that there is no line terminator
> before the `=>`, then we need to treat it as though there was a semicolon.
`var
> fn = (a)\n` would be perfectly valid in ES5, so it's still valid in ES6, but
> there's a syntax error if the next statement starts with `=>`.

To be fair, the restriction in this case makes no sense since you would get a
syntax error in either case.

IIRC, the [no LineTerminator here] was added for future extensions. We have
talked about allowing `=> {}` (optional params) and then the case `x\n=>{}`
would be ambiguous.

Powered by Google App Engine
This is Rietveld 408576698