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

Brace-less Object Literal as a Second Operand on a New Line #2549

Closed
xixixao opened this issue Sep 13, 2012 · 6 comments
Closed

Brace-less Object Literal as a Second Operand on a New Line #2549

xixixao opened this issue Sep 13, 2012 · 6 comments

Comments

@xixixao
Copy link
Contributor

xixixao commented Sep 13, 2012

I know this is similar to quite a few other tickets, but I couldn't find this particular one:

# operator followed by an operand on new line (works)
Tree = Null or
  Something

# brace-less object assignment (works)
BinaryTree =
  node: Num
  left: Self
  right: Self

# brace-less object as an argument (special case, works)
BinaryTree = transform
  node: Num
  left: Self
  right: Self

# brace-less object as an operand on a new line (doesn't work)
BinaryTree = Null or 
  node: Num
  left: Self
  right: Self

What I find the worst is that this is not even an error, just a very silent bug:

BinaryTree = Null || {
  node: Num
};

({
  left: Self,
  right: Self
});

I ran into this when playing with 'contracts'.

@xixixao
Copy link
Contributor Author

xixixao commented Sep 13, 2012

The same result also occurs in this issue, in Satyr's last comment when using \ after return.

@aseemk
Copy link
Contributor

aseemk commented Jan 8, 2013

@satyr
Copy link
Collaborator

satyr commented Jan 8, 2013

It's caused by a combination of little-known features such as newline-suppression, indebt/outdebt, and inline-implicit-object-rule (#1871). Fun stuff.

@vendethiel
Copy link
Collaborator

Seems to work in coco thanks to void assignment tho.

BinaryTree = Null or void =
  node: Num
  left: Self
  right: Self

@satyr
Copy link
Collaborator

satyr commented Jan 8, 2013

  • Use [] = instead and the workaround works in Coffee too.
  • Prefer do in Coco/LiveScript.

@jashkenas
Copy link
Owner

Fixed now on master, thanks to @troels. Enjoy.

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

No branches or pull requests

5 participants