Skip to content

Commit

Permalink
fix: Invalidate text properly so rexpect tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Oct 1, 2019
1 parent e16f662 commit 92e4508
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions repl/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ pub fn run(
use_std_lib: bool,
) -> impl Future<Item = (), Error = gluon::Error> {
let vm = ::gluon::VmBuilder::new().build();
vm.global_env().debug_level(debug_level);
vm.get_Database_mut().use_standard_lib(use_std_lib);
vm.global_env().set_debug_level(debug_level);
vm.get_database_mut().use_standard_lib(use_std_lib);

try_future!(
compile_repl(&vm).map_err(|err| err.emit_string(&vm.get_database().code_map()).unwrap()),
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ pub trait ThreadExt {
expected_type: Option<&ArcType>,
) -> Result<(Arc<SpannedExpr<Symbol>>, ArcType)> {
let vm = self.thread();
{
use salsa::Database;
let mut db = vm.get_database_mut();
if db.module_text(file.into()).as_ref().map(|s| &s[..]).ok() != Some(expr_str) {
db.query_mut(crate::query::ModuleTextQuery)
.invalidate(&file.into());
}
}
let db = get_db_snapshot(&vm);
db.compiler()
.state()
Expand Down
13 changes: 11 additions & 2 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,13 @@ impl CompilerEnv for CompilerDatabase {
self.get_global(id.definition_name())
.map(|g| (Variable::UpVar(g.id.clone()), g.typ.clone()))
} else {
None
let name = id.definition_name();

let globals = self.thread().global_env().get_globals();
globals
.globals
.get(name)
.map(|g| (Variable::UpVar(g.id.clone()), g.typ.clone()))
}
}
}
Expand All @@ -548,7 +554,10 @@ impl TypeEnv for CompilerDatabase {
if id.is_global() {
self.get_global(id.definition_name()).map(|g| g.typ.clone())
} else {
None
let name = id.definition_name();

let globals = self.thread().global_env().get_globals();
globals.globals.get(name).map(|global| global.typ.clone())
}
}

Expand Down

0 comments on commit 92e4508

Please sign in to comment.