mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fix for #891: incorrect inversion of chained comparisons
This commit is contained in:
@@ -1479,6 +1479,9 @@
|
||||
var fst, op, _ref;
|
||||
if (op = INVERSIONS[this.operator]) {
|
||||
this.operator = op;
|
||||
if (this.first.isChainable()) {
|
||||
this.first.invert();
|
||||
}
|
||||
return this;
|
||||
} else if (this.second) {
|
||||
return new Parens(this).invert();
|
||||
|
||||
@@ -1179,6 +1179,7 @@ exports.Op = class Op extends Base
|
||||
invert: ->
|
||||
if op = INVERSIONS[@operator]
|
||||
@operator = op
|
||||
@first.invert() if @first.isChainable()
|
||||
this
|
||||
else if @second
|
||||
new Parens(this).invert()
|
||||
@@ -1207,7 +1208,7 @@ exports.Op = class Op extends Base
|
||||
# true
|
||||
compileChain: (o) ->
|
||||
[@first.second, shared] = @first.second.cache o
|
||||
fst = @first .compile o, LEVEL_OP
|
||||
fst = @first.compile o, LEVEL_OP
|
||||
fst = fst.slice 1, -1 if fst.charAt(0) is '('
|
||||
code = "#{fst} && #{ shared.compile o } #{@operator} #{ @second.compile o, LEVEL_OP }"
|
||||
if o.level < LEVEL_OP then code else "(#{code})"
|
||||
|
||||
Reference in New Issue
Block a user