diff options
author | davidot <davidot@serenityos.org> | 2021-12-29 12:15:29 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-12-29 16:57:23 +0100 |
commit | e179cf25405c5c5d4c329d1782d6e74c8e385669 (patch) | |
tree | 3f0ef40606837c37a0b39f30b698388dc68cd3ac /Userland/Libraries/LibJS/Parser.cpp | |
parent | 56c425eec1d9ff9692f9fb2433b7650bde373992 (diff) | |
download | serenity-e179cf25405c5c5d4c329d1782d6e74c8e385669.zip |
LibJS: Don't VERIFY that the token after 'import' is one of '.' and '('
Although those are the only valid options parse_primary_expression is
sometimes called when only an expression is valid which means it did not
check match_expression and might fail the now removed VERIFY.
Diffstat (limited to 'Userland/Libraries/LibJS/Parser.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Parser.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index b785892cab..7132713aae 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -1425,14 +1425,18 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression() } case TokenType::Import: { auto lookahead_token = next_token(); - VERIFY(lookahead_token.type() == TokenType::Period || lookahead_token.type() == TokenType::ParenOpen); if (lookahead_token.type() == TokenType::ParenOpen) return { parse_import_call() }; - if (auto import_meta = try_parse_import_meta_expression()) { - if (m_program_type != Program::Type::Module) - syntax_error("import.meta is only allowed in modules"); - return { import_meta.release_nonnull() }; + if (lookahead_token.type() == TokenType::Period) { + if (auto import_meta = try_parse_import_meta_expression()) { + if (m_program_type != Program::Type::Module) + syntax_error("import.meta is only allowed in modules"); + return { import_meta.release_nonnull() }; + } + } else { + consume(); + expected("import.meta or import call"); } break; } |