mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:37:34 +00:00
LibJS: Give the undeclared private identifier error more precedence
Before this could give the `must be followed by in` error before the undeclared private identifier error. Fixing the `in` error would not have resolved the other error so this order makes the errors more actionable.
This commit is contained in:
parent
16ac43c9d4
commit
73fcbbb0ee
1 changed files with 2 additions and 2 deletions
|
@ -1520,10 +1520,10 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
|
|||
goto read_as_identifier;
|
||||
return { parse_await_expression() };
|
||||
case TokenType::PrivateIdentifier:
|
||||
if (next_token().type() != TokenType::In)
|
||||
syntax_error("Cannot have a private identifier in expression if not followed by 'in'");
|
||||
if (!is_private_identifier_valid())
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
if (next_token().type() != TokenType::In)
|
||||
syntax_error("Cannot have a private identifier in expression if not followed by 'in'");
|
||||
return { create_ast_node<PrivateIdentifier>({ m_state.current_token.filename(), rule_start.position(), position() }, consume().value()) };
|
||||
default:
|
||||
if (match_identifier_name())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue