function semicolon(optional) {
if (is("punc", ";")) next();
- else if (!optional && !can_insert_semicolon()) expect_token("punc", ";");
+ else if (!optional && !can_insert_semicolon()) expect(";");
}
function parenthesised() {
expect("{");
var a = [];
while (!is("punc", "}")) {
- if (is("eof")) expect_token("punc", "}");
+ if (is("eof")) expect("}");
a.push(statement());
}
next();
expect("{");
var a = [], branch, cur, default_branch, tmp;
while (!is("punc", "}")) {
- if (is("eof")) expect_token("punc", "}");
+ if (is("eof")) expect("}");
if (is("keyword", "case")) {
if (branch) branch.end = prev();
cur = [];
}
function as_name() {
- if (!is("name")) expect_token("name");
var name = S.token.value;
- next();
+ expect_token("name");
return name;
}
if (options.expression) {
handle_regexp();
- return expression();
+ var exp = expression();
+ expect_token("eof");
+ return exp;
}
return function() {
}, code);
});
});
+ it("Should reject invalid syntax under expression=true", function() {
+ assert.throws(function() {
+ UglifyJS.parse("42.g", {
+ expression: true,
+ });
+ }, function(e) {
+ return e instanceof UglifyJS.JS_Parse_Error;
+ });
+ });
});