diff --git a/lib/nodes.js b/lib/nodes.js index 1e9143e3..8c3c0fc2 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1541,7 +1541,7 @@ _results = []; for (i = 0, _len = _ref4.length; i < _len; i++) { item = _ref4[i]; - _results.push((i ? ref : sub) + cmp + item.compile(o, LEVEL_OP)); + _results.push((i ? ref : sub) + cmp + item.compile(o, LEVEL_ACCESS)); } return _results; }).call(this); diff --git a/src/nodes.coffee b/src/nodes.coffee index b899f022..b4fd9700 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1376,7 +1376,7 @@ exports.In = class In extends Base [sub, ref] = @object.cache o, LEVEL_OP [cmp, cnj] = if @negated then [' !== ', ' && '] else [' === ', ' || '] tests = for item, i in @array.base.objects - (if i then ref else sub) + cmp + item.compile o, LEVEL_OP + (if i then ref else sub) + cmp + item.compile o, LEVEL_ACCESS return 'false' if tests.length is 0 tests = tests.join cnj if o.level < LEVEL_OP then tests else "(#{tests})" diff --git a/test/operators.coffee b/test/operators.coffee index ead257e5..abdb9529 100644 --- a/test/operators.coffee +++ b/test/operators.coffee @@ -187,11 +187,16 @@ test "#768: `in` should preserve evaluation order", -> test "#1099: empty array after `in` should compile to `false`", -> eq 1, [5 in []].length eq false, do -> return 0 in [] - + test "#1354: optimized `in` checks should not happen when splats are present", -> a = [6, 9] eq 9 in [3, a...], true +test "#1100: precedence in or-test compilation of `in`", -> + ok 0 in [1 and 0] + ok 0 in [1, 1 and 0] + ok not (0 in [1, 0 or 1]) + # Chained Comparison