mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fixes #2255: global leak with splatted @-params
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user