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

Lexer: Backslash to break line is inconsistent in object comprehension #3909

Closed
nathancarter opened this issue Mar 22, 2015 · 1 comment · Fixed by #4861
Closed

Lexer: Backslash to break line is inconsistent in object comprehension #3909

nathancarter opened this issue Mar 22, 2015 · 1 comment · Fixed by #4861
Labels

Comments

@nathancarter
Copy link

The following compiles correctly into JavaScript if I paste it into the "Try CoffeeScript" box on the CoffeeScript homepage:

x = ( key for own key of obj )

(Is that called "object comprehension?" I don't know.) This is a very small and uninteresting example, but I boiled it down to this case from the more interesting example in which I encountered it.

But we get inconsistent variations if I try to break the line at various points. First, let me list those that compile as expected:

x \
  = ( key for own key of obj )

x = \
  ( key for own key of obj )

x = ( \
  key for own key of obj )

x = ( key \
  for own key of obj )

x = ( key for own key of \
  obj )

x = ( key for own key of obj \
  )

Now, those that don't compile. All say "Error on line 2: unexpected of." And yet, it's the exact same statement, just with breaks at different points.

x = ( key for \
  own key of obj )

x = ( key for own \
  key of obj )

x = ( key for own key \
  of obj )

This is my first issue for this project, so please forgive me if this idiosyncrasy is known or exists more broadly. I did a brief search of the issues before posting, but certainly may have missed it.

@danschumann
Copy link

+1 for fixing the way slash works

image

  1. So, in case one, if we have long argument names, we may make them their own line, but we have to put the first one on like 1, unless we use parenthesis.

  2. You can use the backslash so that you don't need to put arg1 on the same line, but it totally screws up the other 2 args, ( and doesn't care it outdented )

  3. This works and is the way it HAS to be done currently, though ideally, this would be possible without commas.

IMO the 2nd example is a bug, as it doesn't have an outdent error, but if that syntax produced the output of 3, that'd be great.

@GeoffreyBooth GeoffreyBooth changed the title Backslash to break line is inconsistent in object comprehension Lexer: Backslash to break line is inconsistent in object comprehension May 6, 2017
zdenko added a commit to zdenko/coffeescript that referenced this issue Jan 19, 2018
GeoffreyBooth pushed a commit that referenced this issue Jan 28, 2018
@GeoffreyBooth GeoffreyBooth added fixed and removed bug labels Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants