diff --git a/lib/command.js b/lib/command.js index de74a976..60a8e40e 100644 --- a/lib/command.js +++ b/lib/command.js @@ -218,7 +218,7 @@ var o; optionParser = new optparse.OptionParser(SWITCHES, BANNER); o = (options = optionParser.parse(process.argv.slice(2, process.argv.length))); - options.compile = options.compile || !!o.output; + options.compile = options.compile || (!!o.output); options.run = !(o.compile || o.print || o.lint); options.print = !!(o.print || (o.eval || o.stdio && o.compile)); return (sources = options.arguments); diff --git a/lib/nodes.js b/lib/nodes.js index 10cbe8c1..3e90df15 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1288,6 +1288,9 @@ first = _b[0]; firstVar = _b[1]; second = this.second.compile(o); + if (this.second instanceof OpNode) { + second = ("(" + (second) + ")"); + } if (first.match(IDENTIFIER)) { o.scope.find(first); } @@ -1672,7 +1675,7 @@ return this; }; IfNode.prototype.isStatement = function() { - return this.statement = this.statement || !!(this.tags.statement || this.bodyNode().isStatement() || (this.elseBody && this.elseBodyNode().isStatement())); + return this.statement = this.statement || (!!(this.tags.statement || this.bodyNode().isStatement() || (this.elseBody && this.elseBodyNode().isStatement()))); }; IfNode.prototype.compileCondition = function(o) { var _b, _c, _d, _e, cond; diff --git a/src/nodes.coffee b/src/nodes.coffee index 2784aa3d..f66f45b9 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -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}" diff --git a/test/test_operations.coffee b/test/test_operations.coffee index 3151f3f2..5c246041 100644 --- a/test/test_operations.coffee +++ b/test/test_operations.coffee @@ -93,4 +93,10 @@ ok list.join(' ') is '0 5 10' count = 0 list[key()] ?= 100 -ok list.join(' ') is '0 100 5 10' \ No newline at end of file +ok list.join(' ') is '0 100 5 10' + + +# Ensure that RHS is treated as a group. +a = b = false +a and= b or true +ok a is false