Skip to content

Restrict indented return arg to object #4605

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

Conversation

helixbass
Copy link
Collaborator

See discussion in #4599 - this restricts the newly introduced return with indented arg syntax to just allow an indented object. So eg this is allowed:

return
  a: 1

but this is not:

return
  a

Currently non-implicit objects will also work:

return
  {a: 1}

but it should be possible (though perhaps ugly) to disallow this if desired, here's one idea how

Fixes the return equivalent of #3199 eg this will now not split the implicit object:

if 1 then return
  a: 1
  b: 2

Also gets rid of some unintuitive cases that are currently allowed eg this will now not compile:

  return
    a for b in c

rather than compile to the unintuitive:

for (i = 0, len = c.length; i < len; i++) {
  b = c[i];
  return a;
}

@@ -298,3 +298,10 @@ test "#1275: allow indentation before closing brackets", ->
a = 1
)
eq 1, a

test "#3199: throw multiline implicit object", ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

throw -> return

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vendethiel ya I was just being lazy about trying to minimize merge conflicts once this is eventually merged into 2 with #4599 but you're right, updated

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.

3 participants