mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fixing first part of #614 -- improperly cached existential operator, when first operand is a function call.
This commit is contained in:
21
lib/nodes.js
21
lib/nodes.js
@@ -1305,17 +1305,16 @@
|
||||
o.scope.find(first);
|
||||
}
|
||||
if (this.operator === '?=') {
|
||||
return ("" + (first) + " = " + (ExistenceNode.compileTest(o, literal(firstVar))) + " ? " + (firstVar) + " : " + (second));
|
||||
return ("" + (first) + " = " + (ExistenceNode.compileTest(o, literal(firstVar))[0]) + " ? " + (firstVar) + " : " + (second));
|
||||
}
|
||||
return "" + (first) + " = " + (firstVar) + " " + (this.operator.substr(0, 2)) + " " + (second);
|
||||
};
|
||||
OpNode.prototype.compileExistence = function(o) {
|
||||
var _b, first, second, test;
|
||||
_b = [this.first.compile(o), this.second.compile(o)];
|
||||
first = _b[0];
|
||||
second = _b[1];
|
||||
test = ExistenceNode.compileTest(o, this.first);
|
||||
return "" + (test) + " ? " + (first) + " : " + (second);
|
||||
var _b, ref, test;
|
||||
_b = ExistenceNode.compileTest(o, this.first);
|
||||
test = _b[0];
|
||||
ref = _b[1];
|
||||
return "" + (test) + " ? " + (ref) + " : " + (this.second.compile(o));
|
||||
};
|
||||
OpNode.prototype.compileUnary = function(o) {
|
||||
var parts, space;
|
||||
@@ -1439,14 +1438,16 @@
|
||||
ExistenceNode.prototype["class"] = 'ExistenceNode';
|
||||
ExistenceNode.prototype.children = ['expression'];
|
||||
ExistenceNode.prototype.compileNode = function(o) {
|
||||
return ExistenceNode.compileTest(o, this.expression);
|
||||
return ExistenceNode.compileTest(o, this.expression)[0];
|
||||
};
|
||||
ExistenceNode.compileTest = function(o, variable) {
|
||||
var _b, first, second;
|
||||
_b = variable.compileReference(o);
|
||||
_b = variable.compileReference(o, {
|
||||
precompile: true
|
||||
});
|
||||
first = _b[0];
|
||||
second = _b[1];
|
||||
return "(typeof " + (first.compile(o)) + " !== \"undefined\" && " + (second.compile(o)) + " !== null)";
|
||||
return [("(typeof " + (first) + " !== \"undefined\" && " + (second) + " !== null)"), second];
|
||||
};
|
||||
return ExistenceNode;
|
||||
}).call(this);
|
||||
|
||||
Reference in New Issue
Block a user