fixes #2255: global leak with splatted @-params

This commit is contained in:
Michael Ficarra
2012-04-12 23:46:28 -04:00
parent 4043124135
commit 53a82da3f3
3 changed files with 14 additions and 4 deletions

View File

@@ -1683,9 +1683,12 @@
}
_ref4 = this.params;
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
p = _ref4[_k];
if (p.name.value) {
o.scope.add(p.name.value, 'var', true);
p = _ref4[_k].name;
if (p["this"]) {
p = p.properties[0].name;
}
if (p.value) {
o.scope.add(p.value, 'var', true);
}
}
splats = new Assign(new Value(new Arr((function() {

View File

@@ -1176,7 +1176,9 @@ exports.Code = class Code extends Base
for name in @paramNames() # this step must be performed before the others
unless o.scope.check name then o.scope.parameter name
for param in @params when param.splat
o.scope.add p.name.value, 'var', yes for p in @params when p.name.value
for {name: p} in @params
if p.this then p = p.properties[0].name
if p.value then o.scope.add p.value, 'var', yes
splats = new Assign new Value(new Arr(p.asReference o for p in @params)),
new Value new Literal 'arguments'
break

View File

@@ -41,3 +41,8 @@ test "#1973: redefining Array/Object constructors shouldn't confuse __X helpers"
obj = {arr}
for own k of obj
eq arr, obj[k]
test "#2255: global leak with splatted @-params", ->
ok not x?
arrayEq [0], ((@x...) -> @x).call {}, 0
ok not x?