Throw error if new.target is used outside of a function (#402)
This commit is contained in:
committed by
Daniel Tschinder
parent
5e0dc7a689
commit
7a6d495704
@@ -662,7 +662,13 @@ pp.parseNew = function () {
|
||||
const meta = this.parseIdentifier(true);
|
||||
|
||||
if (this.eat(tt.dot)) {
|
||||
return this.parseMetaProperty(node, meta, "target");
|
||||
const metaProp = this.parseMetaProperty(node, meta, "target");
|
||||
|
||||
if (!this.state.inFunction) {
|
||||
this.raise(metaProp.property.start, "new.target can only be used in functions");
|
||||
}
|
||||
|
||||
return metaProp;
|
||||
}
|
||||
|
||||
node.callee = this.parseNoCallExpr();
|
||||
|
||||
Reference in New Issue
Block a user