mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -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);
|
o.scope.find(first);
|
||||||
}
|
}
|
||||||
if (this.operator === '?=') {
|
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;
|
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
|
[first, firstVar] = @first.compileReference o, precompile: yes, assignment: yes
|
||||||
second = @second.compile o
|
second = @second.compile o
|
||||||
o.scope.find(first) if first.match(IDENTIFIER)
|
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"
|
"#first = #firstVar #{ @operator.substr(0, 2) } #second"
|
||||||
|
|
||||||
# If this is an existence operator, we delegate to `ExistenceNode.compileTest`
|
# 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.
|
# Compound assignment should be careful about caching variables.
|
||||||
list = [0, 0, 5, 10]
|
list = [0, null, 5, 10]
|
||||||
count = 1
|
count = 1
|
||||||
key = ->
|
key = ->
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
list[key()] or= 100
|
list[key()] or= 100
|
||||||
ok list.join(' ') is '0 0 5 10'
|
ok list.join(' ') is '0 5 10'
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
list[key()] or= 100
|
list[key()] ?= 100
|
||||||
ok list.join(' ') is '0 100 5 10'
|
ok list.join(' ') is '0 100 5 10'
|
||||||
Reference in New Issue
Block a user