mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(semantic): missing SymbolFlags::Export when identifier used in ExportDefaultDeclaration (#2837)
This commit is contained in:
parent
528744ca0a
commit
947a9f05e8
2 changed files with 18 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ use oxc_ast::{ast::*, AstKind, Trivias, Visit};
|
|||
use oxc_diagnostics::Error;
|
||||
use oxc_span::{CompactStr, SourceType, Span};
|
||||
use oxc_syntax::{
|
||||
identifier::is_identifier_name,
|
||||
module_record::{ExportImportName, ExportLocalName, ModuleRecord},
|
||||
operator::AssignmentOperator,
|
||||
};
|
||||
|
|
@ -333,10 +334,23 @@ impl<'a> SemanticBuilder<'a> {
|
|||
});
|
||||
|
||||
self.module_record.local_export_entries.iter().for_each(|entry| {
|
||||
if let ExportLocalName::Name(name_span) = &entry.local_name {
|
||||
if let Some(symbol_id) = self.scope.get_root_binding(name_span.name()) {
|
||||
self.symbols.union_flag(symbol_id, SymbolFlags::Export);
|
||||
match &entry.local_name {
|
||||
ExportLocalName::Name(name_span) => {
|
||||
if let Some(symbol_id) = self.scope.get_root_binding(name_span.name()) {
|
||||
self.symbols.union_flag(symbol_id, SymbolFlags::Export);
|
||||
}
|
||||
}
|
||||
ExportLocalName::Default(_) => {
|
||||
// export default identifier
|
||||
// ^^^^^^^^^^
|
||||
let identifier = entry.span.source_text(self.source_text);
|
||||
if is_identifier_name(identifier) {
|
||||
if let Some(symbol_id) = self.scope.get_root_binding(identifier) {
|
||||
self.symbols.union_flag(symbol_id, SymbolFlags::Export);
|
||||
}
|
||||
}
|
||||
}
|
||||
ExportLocalName::Null => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ fn test_export_flag() {
|
|||
let tester = SemanticTester::js(
|
||||
"
|
||||
const a = 1;
|
||||
export { a, b, c as d };
|
||||
export { a, b as d };
|
||||
class b {}
|
||||
export default c;
|
||||
function c() {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue