throw a syntax error if you try to use the fat arrow to define a class constructor.

This commit is contained in:
Jeremy Ashkenas
2010-06-30 22:03:20 -04:00
parent 7a5f014014
commit 9a8a707016
2 changed files with 4 additions and 0 deletions

View File

@@ -739,6 +739,9 @@
pvar = _e[0];
func = _e[1];
if (pvar && pvar.base.value === 'constructor' && func instanceof CodeNode) {
if (func.bound) {
throw new Error("cannot define a constructor as a bound function.");
}
func.name = className;
func.body.push(new ReturnNode(literal('this')));
this.variable = new ValueNode(this.variable);