mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibJS: Prefer FunctionDeclaration if a statement begins with "function"
This commit is contained in:
parent
1a10470c1d
commit
73d28a0551
2 changed files with 4 additions and 7 deletions
|
@ -181,10 +181,6 @@ NonnullRefPtr<Program> Parser::parse_program()
|
|||
|
||||
NonnullRefPtr<Statement> Parser::parse_statement()
|
||||
{
|
||||
if (match_expression()) {
|
||||
return adopt(*new ExpressionStatement(parse_expression(0)));
|
||||
}
|
||||
|
||||
switch (m_current_token.type()) {
|
||||
case TokenType::Function:
|
||||
return parse_function_node<FunctionDeclaration>();
|
||||
|
@ -199,6 +195,8 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
|||
case TokenType::For:
|
||||
return parse_for_statement();
|
||||
default:
|
||||
if (match_expression())
|
||||
return adopt(*new ExpressionStatement(parse_expression(0)));
|
||||
m_has_errors = true;
|
||||
expected("statement (missing switch case)");
|
||||
consume();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue