mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Allow division after IdentifierNames in optional chain
The following syntax is valid: ```js e?.example / 1.2 ``` Previously, the `/` would be treated as a unterminated regex literal, because it was calling the regular `consume` instead of `consume_and_allow_division`. This is what is done when parsing IdentifierNames in parse_secondary_expression when a period is encountered. Allows us to parse clients-main-[hash].js on https://ubereats.com/
This commit is contained in:
committed by
Andreas Kling
parent
1bdc41faa1
commit
bd4c29322c
@@ -3561,7 +3561,7 @@ NonnullRefPtr<OptionalChain const> Parser::parse_optional_chain(NonnullRefPtr<Ex
|
||||
default:
|
||||
if (match_identifier_name()) {
|
||||
auto start = position();
|
||||
auto identifier = consume();
|
||||
auto identifier = consume_and_allow_division();
|
||||
chain.append(OptionalChain::MemberReference {
|
||||
create_ast_node<Identifier>({ m_source_code, start, position() }, identifier.DeprecatedFlyString_value()),
|
||||
OptionalChain::Mode::Optional,
|
||||
@@ -3587,7 +3587,7 @@ NonnullRefPtr<OptionalChain const> Parser::parse_optional_chain(NonnullRefPtr<Ex
|
||||
});
|
||||
} else if (match_identifier_name()) {
|
||||
auto start = position();
|
||||
auto identifier = consume();
|
||||
auto identifier = consume_and_allow_division();
|
||||
chain.append(OptionalChain::MemberReference {
|
||||
create_ast_node<Identifier>({ m_source_code, start, position() }, identifier.DeprecatedFlyString_value()),
|
||||
OptionalChain::Mode::NotOptional,
|
||||
|
||||
Reference in New Issue
Block a user