Conditional assignment broken
records = [undefined, {default: false}, {default: true}]
records[0]?.default = true
if records[0]? then records[0].default = true
the last two lines should do the same thing, but the first line causes the compiler to return compile: assignment: unassignable assignee: ConditionalExpression
Is
records[0]?.default = true
a correct CoffeeScript expression?
I can't find any lvalue-?. expression on http://coffeescript.org/ ... which IMO matches the error message which basically says Hey, that expr you used as lvalue is an rvalue only
Yes, it's a correct CoffeeScript expression. Basically everything in coffee is an expression. The tutorial doesn't talk about lvalue or rvalue because there's no point in making simple stuff complex.
Edit: I misunderstood the problem :( Basically you want ? soaking to capture the full assignment expression, not just the access.
~~The problem is records[0]?.default evaluates to the equivalent of records[0] != null ? records[0].default : undefined - so what you are trying to write is something like (records[0] != null ? records[0].default : undefined) = true, which doesn't make sense (certainly not in the alternative branch).~~
~~You probably could give conditional expressions assignable semantics, but it doesn't feel like that is something coffeescript should do, since it's not clear what records[0] should be such that default can be set on it (e.g. when you write records[0]?.default = true, should records[0] become a vanilla object? Why not a string or number or function or prototyped object?).~~
+1 for this issue.