fix corner cases with new.target (#4784)
This commit is contained in:
29
lib/parse.js
29
lib/parse.js
@@ -1737,28 +1737,23 @@ function parse($TEXT, options) {
|
||||
var new_ = function(allow_calls) {
|
||||
var start = S.token;
|
||||
expect_token("operator", "new");
|
||||
var call;
|
||||
if (is("punc", ".") && is_token(peek(), "name", "target")) {
|
||||
next();
|
||||
next();
|
||||
return new AST_NewTarget({
|
||||
name: "new.target",
|
||||
start: start,
|
||||
end: prev(),
|
||||
});
|
||||
}
|
||||
var newexp = expr_atom(false), args;
|
||||
if (is("punc", "(")) {
|
||||
next();
|
||||
args = expr_list(")", !options.strict);
|
||||
call = new AST_NewTarget();
|
||||
} else {
|
||||
args = [];
|
||||
var exp = expr_atom(false), args;
|
||||
if (is("punc", "(")) {
|
||||
next();
|
||||
args = expr_list(")", !options.strict);
|
||||
} else {
|
||||
args = [];
|
||||
}
|
||||
call = new AST_New({ expression: exp, args: args });
|
||||
}
|
||||
var call = new AST_New({
|
||||
start : start,
|
||||
expression : newexp,
|
||||
args : args,
|
||||
end : prev()
|
||||
});
|
||||
call.start = start;
|
||||
call.end = prev();
|
||||
return subscripts(call, allow_calls);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user