Skip to content

Commit 4535f78

Browse files
committed
refactor(fe): if(x != y) {switch(x)} -> switch(x)
1 parent 6d06db4 commit 4535f78

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/quick-lint-js/fe/parse-statement.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,21 +3519,25 @@ void parser::parse_and_visit_import(parse_visitor_base &v) {
35193519
return;
35203520
}
35213521

3522-
if (this->peek().type != token_type::string) {
3523-
switch (this->peek().type) {
3524-
QLJS_CASE_KEYWORD:
3525-
case token_type::identifier:
3526-
this->diag_reporter_->report(diag_cannot_import_from_unquoted_module{
3527-
.import_name = this->peek().identifier_name(),
3528-
});
3529-
break;
3522+
switch (this->peek().type) {
3523+
// import fs from 'fs';
3524+
case token_type::string:
3525+
this->skip();
3526+
break;
35303527

3531-
default:
3532-
QLJS_PARSER_UNIMPLEMENTED();
3533-
break;
3534-
}
3528+
// import foo from bar; // Invalid.
3529+
QLJS_CASE_KEYWORD:
3530+
case token_type::identifier:
3531+
this->diag_reporter_->report(diag_cannot_import_from_unquoted_module{
3532+
.import_name = this->peek().identifier_name(),
3533+
});
3534+
this->skip();
3535+
break;
3536+
3537+
default:
3538+
QLJS_PARSER_UNIMPLEMENTED();
3539+
break;
35353540
}
3536-
this->skip();
35373541

35383542
this->consume_semicolon_after_statement();
35393543
}

0 commit comments

Comments
 (0)