parent
921e45ab2b
commit
864268abb6
@ -382,7 +382,14 @@ const empty = []
|
||||
|
||||
pp.parseNew = function() {
|
||||
let node = this.startNode()
|
||||
this.next()
|
||||
let meta = this.parseIdent(true)
|
||||
if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
|
||||
node.meta = meta
|
||||
node.property = this.parseIdent(true)
|
||||
if (node.property.name !== "target")
|
||||
this.raise(node.property.start, "The only valid meta property for new is new.target")
|
||||
return this.finishNode(node, "MetaProperty")
|
||||
}
|
||||
let start = this.markPosition()
|
||||
node.callee = this.parseSubscripts(this.parseExprAtom(), start, true)
|
||||
if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false)
|
||||
|
||||
@ -269,7 +269,12 @@ lp.parseExprAtom = function() {
|
||||
|
||||
lp.parseNew = function() {
|
||||
let node = this.startNode(), startIndent = this.curIndent, line = this.curLineStart
|
||||
this.next()
|
||||
let meta = this.parseIdent(true)
|
||||
if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
|
||||
node.meta = meta
|
||||
node.property = this.parseIdent(true)
|
||||
return this.finishNode(node, "MetaProperty")
|
||||
}
|
||||
let start = this.storeCurrentPos()
|
||||
node.callee = this.parseSubscripts(this.parseExprAtom(), start, true, startIndent, line)
|
||||
if (this.tok.type == tt.parenL) {
|
||||
|
||||
@ -15579,3 +15579,18 @@ testFail("'use strict'; ({eval = defValue} = obj)", "Assigning to eval in strict
|
||||
testFail("[...eval] = arr", "Assigning to eval in strict mode (1:4)", {ecmaVersion: 6, sourceType: "module"});
|
||||
|
||||
testFail("function* y({yield}) {}", "Binding yield (1:13)", {ecmaVersion: 6});
|
||||
|
||||
test("new.target", {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExpressionStatement",
|
||||
expression: {
|
||||
type: "MetaProperty",
|
||||
meta: {type: "Identifier", name: "new"},
|
||||
property: {type: "Identifier", name: "target"}
|
||||
}
|
||||
}],
|
||||
sourceType: "script"
|
||||
}, {ecmaVersion: 6});
|
||||
|
||||
testFail("new.prop", "The only valid meta property for new is new.target (1:4)", {ecmaVersion: 6});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user