mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Issue #905. Fixing soaked-value-as-a-comprehension-subject ... incorrect LEVEL_TOP.
This commit is contained in:
@@ -1800,7 +1800,7 @@
|
||||
step: this.step
|
||||
}));
|
||||
} else {
|
||||
svar = this.source.compile(o, LEVEL_TOP);
|
||||
svar = this.source.compile(o, LEVEL_PAREN);
|
||||
if ((name || this.own) && !IDENTIFIER.test(svar)) {
|
||||
defPart = "" + this.tab + (ref = scope.freeVariable('ref')) + " = " + svar + ";\n";
|
||||
svar = ref;
|
||||
|
||||
@@ -1438,7 +1438,7 @@ exports.For = class For extends Base
|
||||
if @range
|
||||
forPart = source.compile merge(o, {index: ivar, @step})
|
||||
else
|
||||
svar = @source.compile o, LEVEL_TOP
|
||||
svar = @source.compile o, LEVEL_PAREN
|
||||
if (name or @own) and not IDENTIFIER.test svar
|
||||
defPart = "#{@tab}#{ref = scope.freeVariable 'ref'} = #{svar};\n"
|
||||
svar = ref
|
||||
|
||||
@@ -241,3 +241,11 @@ list = ['one', 'two']
|
||||
|
||||
eq typeof entity, 'undefined'
|
||||
eq facets['two'](), 'two'
|
||||
|
||||
|
||||
# Issue #905. Soaks as the for loop subject.
|
||||
a = {b: {c: [1, 2, 3]}}
|
||||
for d in a.b?.c
|
||||
e = d
|
||||
|
||||
eq e, 3
|
||||
|
||||
Reference in New Issue
Block a user