Skip to content

Commit

Permalink
Handle typechecking error from imports resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebresafegaga committed Mar 27, 2023
1 parent 58df40c commit 62ea376
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lsp/nls/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, ffi::OsString, io};
use codespan::FileId;
use nickel_lang::{
cache::{Cache, CacheError, CacheOp, CachedTerm, EntryState},
error::Error,
error::{Error, ImportError},
typecheck::{self, linearization::Linearization},
};

Expand Down Expand Up @@ -48,8 +48,17 @@ impl CacheExt for Cache {
if let Ok(CacheOp::Done((ids, errors))) = self.resolve_imports(file_id) {
import_errors = errors;
for id in ids {
self.typecheck_with_analysis(id, initial_ctxt, initial_env, lin_cache)
.unwrap();
match self.typecheck_with_analysis(id, initial_ctxt, initial_env, lin_cache) {
Ok(_) => (),
Err(error) => {
// for now just unwrap
let pos = self.get_ref(id).unwrap().pos;
let f = String::from("<somefile>");
let msg = String::from("Couldn't type check this imports content");
let err = ImportError::IOError(f, msg, pos);
import_errors.push(err);
}
}
}
}

Expand Down

0 comments on commit 62ea376

Please sign in to comment.