Skip to content

Conversation

@helixbass
Copy link
Collaborator

The one "unambiguous" thing I saw in #1043 was that a , immediately following -> or => can indicate an empty function body, since otherwise it seems to be a syntax error (ie a function body can't start with a comma). So this uses the rewriter to interpret -> , and => , that way

@GeoffreyBooth I targeted 2, I guess this could safely go on master since the previous meaning was a syntax error, but you seem to prefer only targeting master if really necessary?

@GeoffreyBooth GeoffreyBooth changed the title comma after function glyph [#1043] [CS2] Fix for comma after function glyph [#1043] Jun 25, 2017
@GeoffreyBooth GeoffreyBooth added this to the 2.0.0 milestone Jun 25, 2017
@helixbass
Copy link
Collaborator Author

@GeoffreyBooth actually it was super easy to lump in a fix for #3446 (which is what led me to #1043) / #3845. Same thinking applies: treat -> . or => . as an empty function body followed by chained whatever, and I believe here also the previous meaning would always be a syntax error. So now those chained calls with empty function args work eg:

a
.b ->
.c

So fixes #3446 and #3845, added tests with examples from those issues

@GeoffreyBooth
Copy link
Collaborator

This all looks good to me. @lydell?

Copy link
Collaborator

@lydell lydell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@connec
Copy link
Collaborator

connec commented Jun 26, 2017

This does also allow a -> .b (a(function () {}).b), which is a bit odd.

@helixbass
Copy link
Collaborator Author

@connec ya I'd thought there was no way to distinguish between "inline" chaining and line-break chaining since the leading . suppresses line tokens (eg INDENT/TERMINATOR) but looked more closely and the -> token will have .newLine set in the line-break case. So opened #4590 to distinguish between these so that eg a -> .b will still error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants