fix: import resolution bug

This commit is contained in:
Shunsuke Shibayama 2024-10-05 15:07:28 +09:00
parent 1d16dd724a
commit bccebeac5b
2 changed files with 35 additions and 1 deletions

View file

@ -691,7 +691,16 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
return Ok(());
}
let path = Path::new(&__name__[..]);
let import_path = match cfg.input.resolve_path(path, cfg) {
let resolved = if call.additional_operation().unwrap().is_erg_import() {
cfg.input
.resolve_real_path(path, cfg)
.or_else(|| cfg.input.resolve_decl_path(path, cfg))
} else {
cfg.input
.resolve_decl_path(path, cfg)
.or_else(|| cfg.input.resolve_real_path(path, cfg))
};
let import_path = match resolved {
Some(path) => path,
None if ERG_MODE => {
for _ in 0..600 {

View file

@ -872,6 +872,22 @@ impl Accessor {
}
}
pub fn full_name(&self) -> Option<Str> {
match self {
Self::Ident(ident) => Some(ident.inspect().clone()),
Self::Attr(attr) => Some(
format!(
"{}{}{}",
attr.obj.full_name()?,
attr.ident.vis,
attr.ident.inspect()
)
.into(),
),
_ => None,
}
}
pub fn is_const(&self) -> bool {
match self {
Self::Ident(ident) => ident.is_const(),
@ -6099,6 +6115,15 @@ impl Expr {
pub fn get_name(&self) -> Option<&Str> {
match self {
Expr::Accessor(acc) => acc.name(),
Expr::TypeAscription(ascription) => ascription.expr.get_name(),
_ => None,
}
}
pub fn full_name(&self) -> Option<Str> {
match self {
Expr::Accessor(acc) => acc.full_name(),
Expr::TypeAscription(ascription) => ascription.expr.full_name(),
_ => None,
}
}