mirror of
https://github.com/robertkrimen/otto
synced 2025-10-05 19:19:10 +08:00
Allow semicolon in nested do-while statements. (#463)
In nested do-while statements, a semicolon after the inner `while` threw a parsing error. This change checks for the optional semicolon. Co-authored-by: Brian Graham <bcgraham+github@gmail.com>
This commit is contained in:
parent
762556bdd2
commit
a5b0adea00
|
@ -617,6 +617,8 @@ func TestParser(t *testing.T) {
|
|||
} while (0)
|
||||
`, nil)
|
||||
|
||||
test(`do do; while(0); while(0);`, nil)
|
||||
|
||||
test(`
|
||||
(function(){
|
||||
try {
|
||||
|
|
|
@ -694,6 +694,9 @@ func (self *_parser) parseDoWhileStatement() ast.Statement {
|
|||
node.Test = self.parseExpression()
|
||||
self.expect(token.RIGHT_PARENTHESIS)
|
||||
|
||||
self.implicitSemicolon = true
|
||||
self.optionalSemicolon()
|
||||
|
||||
if self.mode&StoreComments != 0 {
|
||||
self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
|
||||
self.comments.CommentMap.AddComments(node, doComments, ast.DO)
|
||||
|
|
Loading…
Reference in New Issue
Block a user