Fix bad parsing of new new x()() constructs

Fixes #739
This commit is contained in:
Richard van Velzen
2015-08-06 21:27:46 +02:00
committed by Mihai Bazon
parent e3bd223dac
commit fcde6109b0
2 changed files with 15 additions and 3 deletions

View File

@@ -1114,7 +1114,7 @@ function parse($TEXT, options) {
}); });
}; };
var new_ = function() { var new_ = function(allow_calls) {
var start = S.token; var start = S.token;
expect_token("operator", "new"); expect_token("operator", "new");
var newexp = expr_atom(false), args; var newexp = expr_atom(false), args;
@@ -1129,7 +1129,7 @@ function parse($TEXT, options) {
expression : newexp, expression : newexp,
args : args, args : args,
end : prev() end : prev()
}), true); }), allow_calls);
}; };
function as_atom_node() { function as_atom_node() {
@@ -1173,7 +1173,7 @@ function parse($TEXT, options) {
var expr_atom = function(allow_calls) { var expr_atom = function(allow_calls) {
if (is("operator", "new")) { if (is("operator", "new")) {
return new_(); return new_(allow_calls);
} }
var start = S.token; var start = S.token;
if (is("punc")) { if (is("punc")) {

12
test/compress/new.js Normal file
View File

@@ -0,0 +1,12 @@
new_statement: {
input: {
new x(1);
new x(1)(2);
new x(1)(2)(3);
new new x(1);
new new x(1)(2);
new (new x(1))(2);
(new new x(1))(2);
}
expect_exact: "new x(1);new x(1)(2);new x(1)(2)(3);new new x(1);new new x(1)(2);new new x(1)(2);(new new x(1))(2);"
}