fix(semantic): incorrect ExportEntry span for ExportAllDeclaration in ModuleRecord (#2793)

Now the span is ExportAllDeclaration's span
This commit is contained in:
Dunqing 2024-03-25 10:32:02 +08:00 committed by GitHub
parent 525031b7a2
commit b28b61774b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -219,6 +219,7 @@ impl ModuleRecordBuilder {
exported_name.span(), exported_name.span(),
)) ))
}), }),
span: decl.span,
..ExportEntry::default() ..ExportEntry::default()
}; };
self.add_export_entry(export_entry); self.add_export_entry(export_entry);

View file

@ -97,6 +97,7 @@ mod module_record_tests {
let export_entry = ExportEntry { let export_entry = ExportEntry {
module_request: Some(NameSpan::new("mod".into(), Span::new(14, 19))), module_request: Some(NameSpan::new("mod".into(), Span::new(14, 19))),
import_name: ExportImportName::AllButDefault, import_name: ExportImportName::AllButDefault,
span: Span::new(0, 19),
..ExportEntry::default() ..ExportEntry::default()
}; };
assert_eq!(module_record.star_export_entries.len(), 1); assert_eq!(module_record.star_export_entries.len(), 1);
@ -112,6 +113,7 @@ mod module_record_tests {
module_request: Some(NameSpan::new("mod".into(), Span::new(20, 25))), module_request: Some(NameSpan::new("mod".into(), Span::new(20, 25))),
import_name: ExportImportName::All, import_name: ExportImportName::All,
export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(12, 14))), export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(12, 14))),
span: Span::new(0, 25),
..ExportEntry::default() ..ExportEntry::default()
}; };
assert_eq!(module_record.indirect_export_entries.len(), 1); assert_eq!(module_record.indirect_export_entries.len(), 1);
@ -268,7 +270,7 @@ mod module_record_tests {
module_record.indirect_export_entries[1], module_record.indirect_export_entries[1],
ExportEntry { ExportEntry {
module_request: Some(NameSpan::new("mod".into(), Span::new(57, 62))), module_request: Some(NameSpan::new("mod".into(), Span::new(57, 62))),
span: Span::new(0, 0), span: Span::new(37, 63),
import_name: ExportImportName::All, import_name: ExportImportName::All,
export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(49, 51))), export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(49, 51))),
local_name: ExportLocalName::Null, local_name: ExportLocalName::Null,