mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +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
Notes:
sideshowbarker
2024-07-17 14:36:19 +09:00
Author: https://github.com/davidot
Commit: 73fcbbb0ee
Pull-request: https://github.com/SerenityOS/serenity/pull/16094
Reviewed-by: https://github.com/linusg
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