Throw error if new.target is like new.foo
This commit is contained in:
parent
6eaeb19a4a
commit
07785d0003
|
|
@ -1448,7 +1448,7 @@ function parse($TEXT, options) {
|
|||
expect_token("operator", "new");
|
||||
if (is("punc", ".")) {
|
||||
next();
|
||||
expect_token("name");
|
||||
expect_token("name", "target");
|
||||
return subscripts(new AST_NewTarget({
|
||||
start : start,
|
||||
end : prev()
|
||||
|
|
|
|||
|
|
@ -85,4 +85,11 @@ describe("New", function() {
|
|||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("Should check target in new.target", function() {
|
||||
assert.throws(function() {uglify.parse("new.blah")}, function(e) {
|
||||
return e instanceof uglify.JS_Parse_Error
|
||||
&& e.message === "SyntaxError: Unexpected token name «blah», expected name «target»";
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user