diff --git a/crates/samlang-core/src/parser/source_parser.rs b/crates/samlang-core/src/parser/source_parser.rs index b793a2c4..c126fb59 100644 --- a/crates/samlang-core/src/parser/source_parser.rs +++ b/crates/samlang-core/src/parser/source_parser.rs @@ -296,11 +296,15 @@ impl<'a> SourceParser<'a> { for variable in imported_members.iter() { self.class_source_map.insert(variable.name, imported_module); } - if matches!(self.peek(), Token(_, TokenContent::Operator(TokenOp::SEMICOLON))) { - self.consume(); - } + let loc = + if let Token(semicolon_loc, TokenContent::Operator(TokenOp::SEMICOLON)) = self.peek() { + self.consume(); + import_start.union(&semicolon_loc) + } else { + import_start.union(&imported_module_loc) + }; imports.push(ModuleMembersImport { - loc: import_start.union(&imported_module_loc), + loc, imported_members, imported_module, imported_module_loc,