Fixing Issue #589. Compound assignment to an operation should have lower precedence.

This commit is contained in:
Jeremy Ashkenas
2010-08-08 00:07:00 -04:00
parent 1c903450c8
commit b902377304
4 changed files with 13 additions and 3 deletions

View File

@@ -1110,6 +1110,7 @@ exports.OpNode = class OpNode extends BaseNode
compileAssignment: (o) ->
[first, firstVar] = @first.compileReference o, precompile: yes, assignment: yes
second = @second.compile o
second = "(#{second})" if @second instanceof OpNode
o.scope.find(first) if first.match(IDENTIFIER)
return "#{first} = #{ ExistenceNode.compileTest(o, literal(firstVar)) } ? #{firstVar} : #{second}" if @operator is '?='
"#{first} = #{firstVar} #{ @operator.substr(0, 2) } #{second}"