diff options
author | Maxim Brunnmeier <lawl@posteo.de> | 2020-04-05 16:57:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 16:57:01 +0200 |
commit | 2c4a5849f619e4c37b1af52b9ae9cf5d57be15c7 (patch) | |
tree | 1e52144bc0174a73489c295b80fe03c13d8ead85 /Libraries/LibJS/Parser.cpp | |
parent | d077637fd6a3ccd854a7ae62784a760998e7448b (diff) | |
download | serenity-2c4a5849f619e4c37b1af52b9ae9cf5d57be15c7.zip |
LibJS: Fix do..while parsing by consuming parentheses explicitly (#1652)
Before this patch the parser accepted conditions without enclosing
parentheses (like: .."while number < 9").
Diffstat (limited to 'Libraries/LibJS/Parser.cpp')
-rw-r--r-- | Libraries/LibJS/Parser.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp index 3a9bfb2900..5787bc94aa 100644 --- a/Libraries/LibJS/Parser.cpp +++ b/Libraries/LibJS/Parser.cpp @@ -729,9 +729,16 @@ NonnullRefPtr<TryStatement> Parser::parse_try_statement() NonnullRefPtr<DoWhileStatement> Parser::parse_do_while_statement() { consume(TokenType::Do); + auto body = parse_statement(); + consume(TokenType::While); + consume(TokenType::ParenOpen); + auto test = parse_expression(0); + + consume(TokenType::ParenClose); + return create_ast_node<DoWhileStatement>(move(test), move(body)); } |