mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
nested shared scopes don't clobber variables.
This commit is contained in:
@@ -49,9 +49,8 @@
|
||||
return compileScripts();
|
||||
};
|
||||
compileScripts = function() {
|
||||
var _fn, _i, _len, _results;
|
||||
var base, compile, _fn, _i, _len, _results;
|
||||
_fn = function(source) {
|
||||
var base, compile;
|
||||
base = path.join(source);
|
||||
compile = function(source, topLevel) {
|
||||
return path.exists(source, function(exists) {
|
||||
|
||||
@@ -1880,6 +1880,7 @@
|
||||
args.unshift(new Literal('this'));
|
||||
}
|
||||
body.expressions[idx] = new Call(base, args);
|
||||
o.sharedScope = o.scope;
|
||||
defs += this.tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n';
|
||||
}
|
||||
return defs;
|
||||
|
||||
@@ -1498,6 +1498,7 @@ 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 = o.scope
|
||||
defs += @tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n'
|
||||
defs
|
||||
|
||||
|
||||
@@ -219,3 +219,12 @@ odds = while i--
|
||||
i
|
||||
|
||||
ok odds.join(', ') is '5, 3, 1'
|
||||
|
||||
|
||||
# Nested shared scopes.
|
||||
foo = ->
|
||||
for i in [0..7]
|
||||
for j in [0..7]
|
||||
-> i + j
|
||||
|
||||
eq foo()[3][4](), 7
|
||||
Reference in New Issue
Block a user