Skip to content

Commit 26dcf02

Browse files
committed
Remove in empty array optimization
1 parent 39cb881 commit 26dcf02

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/coffee-script/nodes.js

+1-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+1-2
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ exports.In = class In extends Base
17191719
invert: NEGATE
17201720

17211721
compileNode: (o) ->
1722-
if @array instanceof Value and @array.isArray()
1722+
if @array instanceof Value and @array.isArray() and @array.base.objects.length
17231723
for obj in @array.base.objects when obj instanceof Splat
17241724
hasSplat = yes
17251725
break
@@ -1728,7 +1728,6 @@ exports.In = class In extends Base
17281728
@compileLoopTest o
17291729

17301730
compileOrTest: (o) ->
1731-
return [@makeCode("#{!!@negated}")] if @array.base.objects.length is 0
17321731
[sub, ref] = @object.cache o, LEVEL_OP
17331732
[cmp, cnj] = if @negated then [' !== ', ' && '] else [' === ', ' || ']
17341733
tests = []

test/operators.coffee

+4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ test "#1714: lexer bug with raw range `for` followed by `in`", ->
218218
test "#1099: statically determined `not in []` reporting incorrect result", ->
219219
ok 0 not in []
220220

221+
test "#1099: make sure expression tested gets evaluted when array is empty", ->
222+
a = 0
223+
(do -> a = 1) in []
224+
eq a, 1
221225

222226
# Chained Comparison
223227

0 commit comments

Comments
 (0)