mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Fix bugs
This commit is contained in:
parent
afcf21787d
commit
ae15f95191
7 changed files with 159 additions and 57 deletions
|
@ -1522,7 +1522,7 @@ impl Context {
|
|||
}
|
||||
let path = name.split("::").next().unwrap_or(name);
|
||||
let path = path.split('.').next().unwrap_or(path);
|
||||
let path = self.cfg.input.resolve(Path::new(path)).ok()?;
|
||||
let path = self.resolve_path(Path::new(path));
|
||||
if let Some(ctx) = self
|
||||
.mod_cache
|
||||
.as_ref()
|
||||
|
@ -1545,7 +1545,7 @@ impl Context {
|
|||
// NOTE: This needs to be changed if we want to be able to define classes/traits outside of the top level
|
||||
let path = name.split("::").next().unwrap_or(name);
|
||||
let path = path.split('.').next().unwrap_or(path);
|
||||
let path = self.cfg.input.resolve(Path::new(path)).ok()?;
|
||||
let path = self.resolve_path(Path::new(path));
|
||||
if let Some(ctx) = self
|
||||
.mod_cache
|
||||
.as_ref()
|
||||
|
@ -1705,6 +1705,20 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: erg std
|
||||
pub(crate) fn resolve_path(&self, path: &Path) -> PathBuf {
|
||||
if let Ok(path) = self.cfg.input.resolve(path) {
|
||||
path
|
||||
} else if let Ok(path) = erg_pystd_path()
|
||||
.join(format!("{}.d.er", path.display()))
|
||||
.canonicalize()
|
||||
{
|
||||
path
|
||||
} else {
|
||||
PathBuf::from(format!("<builtins>.{}", path.display()))
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: 現在の実装だとimportしたモジュールはどこからでも見れる
|
||||
pub(crate) fn get_mod(&self, name: &str) -> Option<&Context> {
|
||||
let t = self.get_var_info(name).map(|(_, vi)| vi.t.clone()).ok()?;
|
||||
|
@ -1712,18 +1726,7 @@ impl Context {
|
|||
Type::Poly { name, mut params } if &name[..] == "Module" => {
|
||||
let path =
|
||||
option_enum_unwrap!(params.remove(0), TyParam::Value:(ValueObj::Str:(_)))?;
|
||||
let path = Path::new(&path[..]);
|
||||
// TODO: erg std
|
||||
let path = if let Ok(path) = self.cfg.input.resolve(path) {
|
||||
path
|
||||
} else if let Ok(path) = erg_pystd_path()
|
||||
.join(format!("{}.d.er", path.display()))
|
||||
.canonicalize()
|
||||
{
|
||||
path
|
||||
} else {
|
||||
PathBuf::from(format!("<builtins>.{}", path.display()))
|
||||
};
|
||||
let path = self.resolve_path(Path::new(&path[..]));
|
||||
self.mod_cache
|
||||
.as_ref()
|
||||
.and_then(|cache| cache.ref_ctx(&path))
|
||||
|
|
|
@ -797,11 +797,11 @@ impl Context {
|
|||
TypeSpec::PreDeclTy(predecl) => {
|
||||
Ok(self.instantiate_predecl_t(predecl, opt_decl_t, tmp_tv_ctx)?)
|
||||
}
|
||||
TypeSpec::And(lhs, rhs) => Ok(self.union(
|
||||
TypeSpec::And(lhs, rhs) => Ok(self.intersection(
|
||||
&self.instantiate_typespec(lhs, opt_decl_t, tmp_tv_ctx, mode)?,
|
||||
&self.instantiate_typespec(rhs, opt_decl_t, tmp_tv_ctx, mode)?,
|
||||
)),
|
||||
TypeSpec::Or(lhs, rhs) => Ok(self.intersection(
|
||||
TypeSpec::Or(lhs, rhs) => Ok(self.union(
|
||||
&self.instantiate_typespec(lhs, opt_decl_t, tmp_tv_ctx, mode)?,
|
||||
&self.instantiate_typespec(rhs, opt_decl_t, tmp_tv_ctx, mode)?,
|
||||
)),
|
||||
|
|
|
@ -1 +1,14 @@
|
|||
.run!: (args: Str or [Str; _], shell := Bool) => NoneType
|
||||
.CompletedProcess: ClassType
|
||||
.CompletedProcess.args: Str or [Str; _]
|
||||
.CompletedProcess.returncode: Int
|
||||
.CompletedProcess.stdout: Bytes or NoneType
|
||||
.CompletedProcess.stderr: Bytes or NoneType
|
||||
|
||||
.run!: (
|
||||
args: Str or [Str; _],
|
||||
stdin: File! or NoneType := NoneType,
|
||||
stdout: File! or NoneType := NoneType,
|
||||
stderr: File! or NoneType := NoneType,
|
||||
capture_output := Bool,
|
||||
shell := Bool,
|
||||
) => .CompletedProcess
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue