#2445 Js: Invalid left-hand side in assignment

Jeremy Criquet Tue 25 Aug 2015

Compiling something like this in JavaScript:

b := false
a := b || ( b = true )

Compiles into this:

var b = false;
var a = (b || b = true);

And produces this error:

Uncaught ReferenceError: Invalid left-hand side in assignment

Based on operator presidence, this will not compile in Fantom (makes sense):

a := b || b = true

The reason for that is the same reason why JavaScript is complaining.

It should instead compile to:

var a = (b || (b = true));

Jeremy Criquet Tue 25 Aug 2015

If you're wondering why I'm doing this, here's a better example:

trimStr := "A quick brown"
textStr := "A quick brown fox jumps over the lazy dog"
trim := trimStr.split
stop := false
textStr = text.split.findAll |word, i| { stop || ( stop = trim.getSafe( i ) != word ) }.join( " " )

There's a way around this, but I just thought I'd point the bug out.

andy Tue 25 Aug 2015

Ticket promoted to #2445 and assigned to andy

Login or Signup to reply.