fixing issue 542. Parse error with leading object literal as part of operation.
This commit is contained in:
parent
27e5c42023
commit
ac2f814eb4
|
@ -323,7 +323,7 @@
|
|||
],
|
||||
SimpleArgs: [
|
||||
o("Expression"), o("SimpleArgs , Expression", function() {
|
||||
return ($1 instanceof Array) ? $1.concat([$3]) : [$1].concat([$3]);
|
||||
return $1 instanceof Array ? $1.concat([$3]) : [$1].concat([$3]);
|
||||
})
|
||||
],
|
||||
Try: [
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
_b = array;
|
||||
for (_a = 0, _c = _b.length; _a < _c; _a++) {
|
||||
item = _b[_a];
|
||||
(item instanceof Array) ? (memo = memo.concat(item)) : memo.push(item);
|
||||
item instanceof Array ? (memo = memo.concat(item)) : memo.push(item);
|
||||
}
|
||||
return memo;
|
||||
});
|
||||
|
|
11
lib/nodes.js
11
lib/nodes.js
|
@ -464,7 +464,7 @@
|
|||
_c = this.args;
|
||||
for (_b = 0, _d = _c.length; _b < _d; _b++) {
|
||||
arg = _c[_b];
|
||||
(arg instanceof SplatNode) ? (compilation = this.compileSplat(o)) : null;
|
||||
arg instanceof SplatNode ? (compilation = this.compileSplat(o)) : null;
|
||||
}
|
||||
if (!(compilation)) {
|
||||
args = (function() {
|
||||
|
@ -687,7 +687,7 @@
|
|||
if (i === this.properties.length - 1) {
|
||||
join = '';
|
||||
}
|
||||
indent = (prop instanceof CommentNode) ? '' : this.idt(1);
|
||||
indent = prop instanceof CommentNode ? '' : this.idt(1);
|
||||
if (!(prop instanceof AssignNode || prop instanceof CommentNode)) {
|
||||
prop = new AssignNode(prop, prop, 'object');
|
||||
}
|
||||
|
@ -1140,6 +1140,7 @@
|
|||
this.second = second;
|
||||
this.operator = this.CONVERSIONS[operator] || operator;
|
||||
this.flip = !!flip;
|
||||
this.first instanceof ValueNode && this.first.base instanceof ObjectNode ? (this.first = new ParentheticalNode(this.first)) : null;
|
||||
return this;
|
||||
};
|
||||
__extends(OpNode, BaseNode);
|
||||
|
@ -1373,7 +1374,7 @@
|
|||
if (code.substr(l - 1, 1) === ';') {
|
||||
code = code.substr(o, l - 1);
|
||||
}
|
||||
return (this.expression instanceof AssignNode) ? code : ("(" + code + ")");
|
||||
return this.expression instanceof AssignNode ? code : ("(" + code + ")");
|
||||
};
|
||||
return ParentheticalNode;
|
||||
})();
|
||||
|
@ -1519,8 +1520,6 @@
|
|||
this.tags = tags || {};
|
||||
if (this.tags.invert) {
|
||||
this.condition = new OpNode('!', new ParentheticalNode(this.condition));
|
||||
} else if (this.condition instanceof OpNode && this.condition.operator === 'instanceof') {
|
||||
this.condition = new ParentheticalNode(this.condition);
|
||||
}
|
||||
this.elseBody = null;
|
||||
this.isChain = false;
|
||||
|
@ -1606,7 +1605,7 @@
|
|||
}
|
||||
};
|
||||
IfNode.prototype.ensureExpressions = function(node) {
|
||||
return (node instanceof Expressions) ? node : new Expressions([node]);
|
||||
return node instanceof Expressions ? node : new Expressions([node]);
|
||||
};
|
||||
IfNode.prototype.compileStatement = function(o) {
|
||||
var body, child, comDent, condO, elsePart, ifDent, ifPart;
|
||||
|
|
|
@ -1039,6 +1039,8 @@ exports.OpNode = class OpNode extends BaseNode
|
|||
@second = second
|
||||
@operator = @CONVERSIONS[operator] or operator
|
||||
@flip = !!flip
|
||||
if @first instanceof ValueNode and @first.base instanceof ObjectNode
|
||||
@first = new ParentheticalNode @first
|
||||
|
||||
isUnary: ->
|
||||
not @second
|
||||
|
@ -1335,10 +1337,7 @@ exports.IfNode = class IfNode extends BaseNode
|
|||
@condition = condition
|
||||
@body = body
|
||||
@tags = tags or {}
|
||||
if @tags.invert
|
||||
@condition = new OpNode('!', new ParentheticalNode(@condition))
|
||||
else if @condition instanceof OpNode and @condition.operator is 'instanceof'
|
||||
@condition = new ParentheticalNode(@condition)
|
||||
@condition = new OpNode('!', new ParentheticalNode(@condition)) if @tags.invert
|
||||
@elseBody = null
|
||||
@isChain = false
|
||||
|
||||
|
|
|
@ -74,3 +74,6 @@ if {} instanceof Object
|
|||
ok yes
|
||||
else
|
||||
ok no
|
||||
|
||||
result = {} + {}
|
||||
ok result is '[object Object][object Object]'
|
Loading…
Reference in New Issue