chore: resolve decl package path

This commit is contained in:
Shunsuke Shibayama 2024-02-10 01:20:31 +09:00
parent 027009680a
commit 14bf431c57
5 changed files with 36 additions and 14 deletions

View file

@ -13,7 +13,7 @@ use std::time::{Duration, SystemTime};
use erg_common::config::ErgMode;
use erg_common::config::ErgConfig;
use erg_common::consts::ELS;
use erg_common::consts::{DEBUG_MODE, ELS};
use erg_common::debug_power_assert;
use erg_common::dict::Dict;
use erg_common::env::is_std_decl_path;
@ -525,7 +525,11 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
.spawn()
.and_then(|mut child| child.wait())
{
if let Some(path) = self.cfg.input.resolve_decl_path(Path::new(&__name__[..])) {
if let Some(path) = self
.cfg
.input
.resolve_decl_path(Path::new(&__name__[..]), &self.cfg)
{
let size = metadata(&path).unwrap().len();
// if pylyzer crashed
if !status.success() && size == 0 {
@ -728,7 +732,7 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
// return;
} else if let Some(inliner) = self.inlines.get(path).cloned() {
self.build_deps_and_module(&inliner, graph);
} else {
} else if DEBUG_MODE {
todo!("{path} is not found in self.inlines and self.asts");
}
}

View file

@ -1445,7 +1445,7 @@ pub(crate) fn resolve_decl_path_func(
return Err(type_mismatch("Str", other, "Path"));
}
};
let Some(path) = ctx.cfg.input.resolve_decl_path(path) else {
let Some(path) = ctx.cfg.input.resolve_decl_path(path, &ctx.cfg) else {
return Err(ErrorCore::new(
vec![SubMessage::only_loc(Location::Unknown)],
format!("Path {} is not found", path.display()),

View file

@ -2262,7 +2262,11 @@ impl Context {
}
fn get_decl_path(&self, __name__: &Str, loc: &impl Locational) -> CompileResult<PathBuf> {
match self.cfg.input.resolve_decl_path(Path::new(&__name__[..])) {
match self
.cfg
.input
.resolve_decl_path(Path::new(&__name__[..]), &self.cfg)
{
Some(path) => {
if self.cfg.input.decl_file_is(&path) {
return Ok(path);

View file

@ -483,7 +483,7 @@ impl<'a> HIRLinker<'a> {
let mod_path = self
.cfg
.input
.resolve_decl_path(Path::new(&mod_name_str[..]))
.resolve_decl_path(Path::new(&mod_name_str[..]), self.cfg)
.unwrap();
if !mod_path
.canonicalize()