Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CS2] return and export default can now accept implicit objects #4532

Merged
merged 5 commits into from
May 2, 2017

Conversation

GeoffreyBooth
Copy link
Collaborator

Fixes #1263, probably others. This now compiles:

return
  a: 1
  b: 2

As does the same for export default.

@vendethiel
Copy link
Collaborator

Very nice 👍

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.

If it works I guess we’re fine. Can’t really tell how this works and what it affects.

@GeoffreyBooth
Copy link
Collaborator Author

Well, it was previously a compiler error, so it’s not a breaking change. I guess the question is, are we opening ourselves up to allowing the compiler to output too much? Are there any edge cases where something indented on a new line after a return wouldn’t be returnable, that we should error on?

@@ -790,7 +790,7 @@ exports.Lexer = class Lexer
LINE_CONTINUER.test(@chunk) or
@tag() in ['\\', '.', '?.', '?::', 'UNARY', 'MATH', 'UNARY_MATH', '+', '-',
'**', 'SHIFT', 'RELATION', 'COMPARE', '&', '^', '|', '&&', '||',
'BIN?', 'THROW', 'EXTENDS']
'BIN?', 'THROW', 'EXTENDS', 'DEFAULT']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of interest, but would adding 'RETURN" here achieve the same thing as 75f6912?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was my first thought, but it's too permissive. This causes a return line continuation even if the line following the return is the same indentation, which we definitely don't want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, good point, that makes sense!

@GeoffreyBooth GeoffreyBooth merged commit 2f9ab1d into jashkenas:2 May 2, 2017
@GeoffreyBooth GeoffreyBooth deleted the return-object branch May 2, 2017 02:26
GeoffreyBooth added a commit to GeoffreyBooth/coffeescript that referenced this pull request May 2, 2017
GeoffreyBooth added a commit to GeoffreyBooth/coffeescript that referenced this pull request May 2, 2017
@GeoffreyBooth
Copy link
Collaborator Author

Also merged into master: 26cb24a

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

Successfully merging this pull request may close these issues.

4 participants