Issue #948. A plucked direct call should not have shared scope. (kinda defeats the whole point.)

This commit is contained in:
Jeremy Ashkenas 2010-12-18 10:41:44 -05:00
parent bc4498e018
commit 640ba7d69e
4 changed files with 11 additions and 3 deletions

View File

@ -50,8 +50,9 @@
return compileScripts();
};
compileScripts = function() {
var base, compile, source, _fn, _i, _len, _results;
var source, _fn, _i, _len, _results;
_fn = function(source) {
var base, compile;
base = path.join(source);
compile = function(source, topLevel) {
return path.exists(source, function(exists) {

View File

@ -1884,7 +1884,6 @@
args.unshift(new Literal('this'));
}
body.expressions[idx] = new Call(base, args);
o.sharedScope = true;
defs += this.tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n';
}
return defs;

View File

@ -1500,7 +1500,6 @@ exports.For = class For extends Base
[val.base, base] = [base, val]
args.unshift new Literal 'this'
body.expressions[idx] = new Call base, args
o.sharedScope = yes
defs += @tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n'
defs

View File

@ -249,3 +249,12 @@ for d in a.b?.c
e = d
eq e, 3
# Issue #948. Capturing loop variables.
funcs = []
for y in [1, 2, 3]
z = y
funcs.push -> "y is #{y} and z is #{z}"
eq funcs[1](), "y is 2 and z is 2"