Skip to content

Commit

Permalink
chore: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Jun 15, 2024
1 parent f489df2 commit 5cf3acb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
22 changes: 18 additions & 4 deletions crates/els/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
(artifact, CheckStatus::Failed)
}
};
let ast = self.build_ast(&uri).ok();
let ast = match self.build_ast(&uri) {
Ok(ast) => Some(ast),
Err(BuildASTError::ParseError(err)) => err.ast,
_ => None,
};
let Some(ctx) = checker.pop_context() else {
_log!(self, "context not found");
return Ok(());
Expand Down Expand Up @@ -205,9 +209,19 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
crate::_log!(self, "AST not found: {uri}");
return Ok(());
};
let Ok(new) = self.build_ast(&uri) else {
crate::_log!(self, "AST not found: {uri}");
return Ok(());
let new = match self.build_ast(&uri) {
Ok(ast) => ast,
Err(BuildASTError::ParseError(err)) => {
if let Some(new) = err.ast {
new
} else {
return Ok(());
}
}
_ => {
crate::_log!(self, "AST not found: {uri}");
return Ok(());
}
};
let ast_diff = ASTDiff::diff(old, &new);
crate::_log!(self, "diff: {ast_diff}");
Expand Down
4 changes: 2 additions & 2 deletions crates/erg_common/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn _erg_pkgs_path() -> PathBuf {
.join("pkgs")
.canonicalize()
.unwrap_or_else(|_| {
eprintln!("{RED}[ERR] ERG_PATH/lib/pkgs not found {RESET}");
// eprintln!("{RED}[ERR] ERG_PATH/lib/pkgs not found {RESET}");
fallback_erg_path().join("lib/pkgs")
})
}
Expand All @@ -79,7 +79,7 @@ fn _python_site_packages() -> impl Iterator<Item = PathBuf> {
.filter(|p| p.ends_with("site-packages"))
.map(|p| {
p.canonicalize().unwrap_or_else(|_| {
eprintln!("{RED}[ERR] {} not found {RESET}", p.display());
// eprintln!("{RED}[ERR] {} not found {RESET}", p.display());
fallback_erg_path().join("lib/pkgs")
})
})
Expand Down
1 change: 1 addition & 0 deletions crates/erg_common/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ pub trait Runnable: Sized + Default + New {
self.cfg_mut().input = input;
}
fn start_message(&self) -> String {
#[allow(clippy::const_is_empty)]
if GIT_HASH_SHORT.is_empty() {
format!("{} {SEMVER} ({BUILD_DATE}) on {ARCH}/{OS}\n", Self::NAME)
} else {
Expand Down
22 changes: 16 additions & 6 deletions crates/erg_compiler/context/inquire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,10 @@ impl Context {
return Triple::Err(errs);
}
drop(list);
self.sub_unify(obj.ref_t(), self_t, obj, Some(&"self".into()))
.unwrap();
let res = self.sub_unify(obj.ref_t(), self_t, obj, Some(&"self".into()));
if DEBUG_MODE {
res.unwrap();
}
}
return Triple::Ok(vi);
}
Expand Down Expand Up @@ -842,8 +844,10 @@ impl Context {
.is_ok()
{
drop(list);
self.sub_unify(obj.ref_t(), &method.definition_type, obj, None)
.unwrap();
let res = self.sub_unify(obj.ref_t(), &method.definition_type, obj, None);
if DEBUG_MODE {
res.unwrap();
}
return Triple::Ok(method.method_info.clone());
}
}
Expand Down Expand Up @@ -1357,7 +1361,10 @@ impl Context {
// HACK: change this func's return type to TyCheckResult<Type>
.map_err(|mut errs| errs.remove(0))?;
drop(list);
self.sub_unify(obj.ref_t(), &def_t, obj, None).unwrap();
let res = self.sub_unify(obj.ref_t(), &def_t, obj, None);
if DEBUG_MODE {
res.unwrap();
}
return Ok(method.method_info.clone());
}
Triple::Err(err) => {
Expand Down Expand Up @@ -1483,7 +1490,10 @@ impl Context {
// HACK: change this func's return type to TyCheckResult<Type>
.map_err(|mut errs| errs.remove(0))?;
drop(list);
self.sub_unify(obj.ref_t(), &def_t, obj, None).unwrap();
let res = self.sub_unify(obj.ref_t(), &def_t, obj, None);
if DEBUG_MODE {
res.unwrap();
}
return Ok(method.method_info.clone());
}
Triple::Err(err) => {
Expand Down

0 comments on commit 5cf3acb

Please sign in to comment.