@@ -1812,10 +1812,17 @@ var AST_Super = DEFNODE("Super", null, {
|
|||||||
var AST_This = DEFNODE("This", null, {
|
var AST_This = DEFNODE("This", null, {
|
||||||
$documentation: "The `this` symbol",
|
$documentation: "The `this` symbol",
|
||||||
_validate: function() {
|
_validate: function() {
|
||||||
if (this.name !== "this") throw new Error('name must be "this"');
|
if (this.TYPE == "This" && this.name !== "this") throw new Error('name must be "this"');
|
||||||
},
|
},
|
||||||
}, AST_ObjectIdentity);
|
}, AST_ObjectIdentity);
|
||||||
|
|
||||||
|
var AST_NewTarget = DEFNODE("NewTarget", null, {
|
||||||
|
$documentation: "The `new.target` symbol",
|
||||||
|
_validate: function() {
|
||||||
|
if (this.name !== "new.target") throw new Error('name must be "new.target": ' + this.name);
|
||||||
|
},
|
||||||
|
}, AST_This);
|
||||||
|
|
||||||
var AST_Template = DEFNODE("Template", "expressions strings tag", {
|
var AST_Template = DEFNODE("Template", "expressions strings tag", {
|
||||||
$documentation: "A template literal, i.e. tag`str1${expr1}...strN${exprN}strN+1`",
|
$documentation: "A template literal, i.e. tag`str1${expr1}...strN${exprN}strN+1`",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
|
|||||||
@@ -1736,6 +1736,15 @@ function parse($TEXT, options) {
|
|||||||
var new_ = function(allow_calls) {
|
var new_ = function(allow_calls) {
|
||||||
var start = S.token;
|
var start = S.token;
|
||||||
expect_token("operator", "new");
|
expect_token("operator", "new");
|
||||||
|
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;
|
var newexp = expr_atom(false), args;
|
||||||
if (is("punc", "(")) {
|
if (is("punc", "(")) {
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -1225,3 +1225,22 @@ issue_4725_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_target: {
|
||||||
|
input: {
|
||||||
|
console.log(typeof new class {
|
||||||
|
constructor() {
|
||||||
|
this.f = () => new.target;
|
||||||
|
}
|
||||||
|
}().f());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof new class {
|
||||||
|
constructor() {
|
||||||
|
this.f = () => new.target;
|
||||||
|
}
|
||||||
|
}().f());
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -5752,3 +5752,22 @@ issue_4725_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_target: {
|
||||||
|
input: {
|
||||||
|
console.log(typeof new function() {
|
||||||
|
return new.target;
|
||||||
|
}, function() {
|
||||||
|
return new.target;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof new function() {
|
||||||
|
return new.target;
|
||||||
|
}(), function() {
|
||||||
|
return new.target;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "function undefined"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user