Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Keyword arguments breaking objects #2179

Closed
neocotic opened this Issue · 4 comments

5 participants

@neocotic

Supposedly this is bad. Why?

getInfo 'fubar', yes
object =
  foo: getInfo 'foo', 0
  bar: getInfo 'bar', 'yes'
  fu:  getInfo 'fu', yes
  baz: getInfo 'baz', yes, 1

Example

PARSE ERROR ON LINE 5: UNEXPECTED ','

I also get this error for line 6 if line 5 is fixed. The workaround I'm currently using is to wrap the arguments in parenthesis. This isn't a big problem but does ruin the code style slightly.

@TrevorBurnham
Collaborator

Confirmed... this is super-weird. It seems to occur whenever you use a boolean literal (yes/on/true or no/off/false) as the second-or-later argument to a function within an object literal when there are no explicit parentheses or curly braces. Here's the simplest example I can find:

a: func 1, true

Maybe @michaelficarra can shed some light on this?

@neocotic

I thought it was limited to boolean literals at first as well but it seems to include null, undefined, this etc. as well.

@michaelficarra
Collaborator

@TrevorBurnham: It's not just boolean literals:

$ coffee -ep 'a: f 0, !1'
Error: Parse error on line 1: Unexpected ','
$ coffee -ep 'a: f 0, +b'
Error: Parse error on line 1: Unexpected ','

and so on... I think we might have an open issue for this already.

@Ricket

If you explicitly put curly braces around the four properties to declare object as an object to the compiler, there is no problem. Alternatively if you put parentheses around each of the function calls, there is no problem. And if you add newlines so that the function calls are indented on a new line after each property name and colon, there is no problem.

Clearly this is a bug (maybe) in the compiler's inference of objects.

@vendethiel vendethiel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.