mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fixes #2630 -- Class bodies shouldn't be able to reference arguments.
This commit is contained in:
@@ -2886,6 +2886,9 @@
|
||||
func = new Code([], Block.wrap([expressions]));
|
||||
args = [];
|
||||
if ((mentionsArgs = expressions.contains(this.literalArgs)) || expressions.contains(this.literalThis)) {
|
||||
if (mentionsArgs && expressions.classBody) {
|
||||
throw SyntaxError("Class bodies don't have arguments");
|
||||
}
|
||||
meth = new Literal(mentionsArgs ? 'apply' : 'call');
|
||||
args = [new Literal('this')];
|
||||
if (mentionsArgs) {
|
||||
|
||||
@@ -1934,6 +1934,8 @@ Closure =
|
||||
func = new Code [], Block.wrap [expressions]
|
||||
args = []
|
||||
if (mentionsArgs = expressions.contains @literalArgs) or expressions.contains @literalThis
|
||||
if mentionsArgs and expressions.classBody
|
||||
throw SyntaxError "Class bodies don't have arguments"
|
||||
meth = new Literal if mentionsArgs then 'apply' else 'call'
|
||||
args = [new Literal 'this']
|
||||
args.push new Literal 'arguments' if mentionsArgs
|
||||
|
||||
@@ -676,3 +676,7 @@ test "#2052: classes should work in strict mode", ->
|
||||
class A
|
||||
catch e
|
||||
ok no
|
||||
|
||||
test "#2630: class bodies can't reference arguments", ->
|
||||
throws ->
|
||||
CoffeeScript.compile('class Test then arguments')
|
||||
|
||||
Reference in New Issue
Block a user