Make semicolon optional in do-while in >=ES6
This commit is contained in:
parent
e252acbe67
commit
53d98f1175
5
acorn.js
5
acorn.js
@ -1605,7 +1605,10 @@
|
||||
labels.pop();
|
||||
expect(_while);
|
||||
node.test = parseParenExpression();
|
||||
semicolon();
|
||||
if (options.ecmaVersion >= 6)
|
||||
eat(_semi);
|
||||
else
|
||||
semicolon();
|
||||
return finishNode(node, "DoWhileStatement");
|
||||
}
|
||||
|
||||
|
||||
@ -13605,6 +13605,52 @@ test("/[a-z]/u", {
|
||||
ecmaVersion: 6
|
||||
});
|
||||
|
||||
|
||||
test("do {} while (false) foo();", {
|
||||
type: "Program",
|
||||
start: 0,
|
||||
end: 26,
|
||||
body: [
|
||||
{
|
||||
type: "DoWhileStatement",
|
||||
start: 0,
|
||||
end: 19,
|
||||
body: {
|
||||
type: "BlockStatement",
|
||||
start: 3,
|
||||
end: 5,
|
||||
body: []
|
||||
},
|
||||
test: {
|
||||
type: "Literal",
|
||||
start: 13,
|
||||
end: 18,
|
||||
value: false,
|
||||
raw: "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "ExpressionStatement",
|
||||
start: 20,
|
||||
end: 26,
|
||||
expression: {
|
||||
type: "CallExpression",
|
||||
start: 20,
|
||||
end: 25,
|
||||
callee: {
|
||||
type: "Identifier",
|
||||
start: 20,
|
||||
end: 23,
|
||||
name: "foo"
|
||||
},
|
||||
arguments: []
|
||||
}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
ecmaVersion: 6
|
||||
});
|
||||
|
||||
// Harmony Invalid syntax
|
||||
|
||||
testFail("0o", "Expected number in radix 8 (1:2)", {ecmaVersion: 6});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user