1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fix for #891: incorrect inversion of chained comparisons

This commit is contained in:
Michael Ficarra 2010-12-02 12:55:53 -05:00
parent 56e10f9bce
commit 992324b425
2 changed files with 5 additions and 1 deletions

View file

@ -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();

View file

@ -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})"