mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fixing up compout assignment for ?=, which was using a sligtly different path.
This commit is contained in:
@@ -1293,7 +1293,7 @@
|
||||
o.scope.find(first);
|
||||
}
|
||||
if (this.operator === '?=') {
|
||||
return ("" + first + " = " + (ExistenceNode.compileTest(o, this.first)) + " ? " + firstVar + " : " + second);
|
||||
return ("" + first + " = " + (ExistenceNode.compileTest(o, literal(firstVar))) + " ? " + firstVar + " : " + second);
|
||||
}
|
||||
return "" + first + " = " + firstVar + " " + (this.operator.substr(0, 2)) + " " + second;
|
||||
};
|
||||
|
||||
@@ -1112,7 +1112,7 @@ exports.OpNode = class OpNode extends BaseNode
|
||||
[first, firstVar] = @first.compileReference o, precompile: yes, assignment: yes
|
||||
second = @second.compile o
|
||||
o.scope.find(first) if first.match(IDENTIFIER)
|
||||
return "#first = #{ ExistenceNode.compileTest(o, @first) } ? #firstVar : #second" if @operator is '?='
|
||||
return "#first = #{ ExistenceNode.compileTest(o, literal(firstVar)) } ? #firstVar : #second" if @operator is '?='
|
||||
"#first = #firstVar #{ @operator.substr(0, 2) } #second"
|
||||
|
||||
# If this is an existence operator, we delegate to `ExistenceNode.compileTest`
|
||||
|
||||
@@ -82,15 +82,15 @@ ok two is 'two'
|
||||
|
||||
|
||||
# Compound assignment should be careful about caching variables.
|
||||
list = [0, 0, 5, 10]
|
||||
list = [0, null, 5, 10]
|
||||
count = 1
|
||||
key = ->
|
||||
count += 1
|
||||
|
||||
list[key()] or= 100
|
||||
ok list.join(' ') is '0 0 5 10'
|
||||
ok list.join(' ') is '0 5 10'
|
||||
|
||||
count = 0
|
||||
|
||||
list[key()] or= 100
|
||||
list[key()] ?= 100
|
||||
ok list.join(' ') is '0 100 5 10'
|
||||
Reference in New Issue
Block a user