coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

bind specialty?

Open dvv opened this issue 15 years ago • 3 comments

Hi!

Can't compile

fn = (a, b, c) -> 'bar'
obj =
    foo: fn.bind {}, 369, null

while

fn = (a, b, c) -> 'bar'
obj =
    foo: fn.bind({}, 369, null)

is fine.

What can be the problem?

TIA, --Vladimir

dvv avatar Jan 22 '11 20:01 dvv

It's rewriting it to { foo: fn.bind({}, 369) }, null Weird.

zmthy avatar Jan 22 '11 21:01 zmthy

# Not Working
f = ->
obj = 
    s: f 1, null

f = ->
obj = 
    s: f 1, true

f = ->
obj = 
    s: f 1, undefined



# Even weird . . .
f = ->
obj = 
    s: f 1, null, 1

f = ->
obj = 
    s: f 1, true, 5

f = ->
obj = 
    s: f 1, undefined, 7



# Working
f = ->
obj = 
    s: f null, 1

f = ->
obj = 
    s: f true, 1

f = ->
obj = 
    s: f undefined, 1

The working scenario is when the reserved word that has "value" (true, null, etc.) is passed as first argument in a function in whose return value is passed in a property of an object.

OnesimusUnbound avatar Mar 23 '11 09:03 OnesimusUnbound

Fixed in 1.6.0.

jashkenas avatar Mar 05 '13 08:03 jashkenas