1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibJS: Fix parsing of IfStatement, fixes #1829

This commit is contained in:
Stephan Unverwerth 2020-04-18 14:00:43 +02:00 committed by Andreas Kling
parent 3072f9fd82
commit cebb619f8e
2 changed files with 23 additions and 1 deletions

View file

@ -664,8 +664,11 @@ NonnullRefPtr<ReturnStatement> Parser::parse_return_statement()
return create_ast_node<ReturnStatement>(nullptr);
if (match_expression()) {
return create_ast_node<ReturnStatement>(parse_expression(0));
auto expression = parse_expression(0);
consume_or_insert_semicolon();
return create_ast_node<ReturnStatement>(move(expression));
}
consume_or_insert_semicolon();
return create_ast_node<ReturnStatement>(nullptr);
}