Throwing proper error when "constructor" is not a function within a class body.

This commit is contained in:
Stan Angeloff
2010-04-03 21:43:42 +03:00
parent d1aaed4430
commit 9958cedd89
2 changed files with 4 additions and 0 deletions

View File

@@ -821,6 +821,9 @@
pvar = prop.variable;
if (pvar && pvar.base.value === 'constructor') {
func = prop.value;
if (!(func instanceof CodeNode)) {
throw new Error("'" + (pvar.base.value) + "' must be a function in 'class " + (this.variable.base.value) + "'.");
}
func.body.push(new ReturnNode(literal('this')));
constructor = new AssignNode(this.variable, func);
} else {