diff --git a/lib/src/metta/runner/mod.rs b/lib/src/metta/runner/mod.rs index 72b414d99..083e1b0c9 100644 --- a/lib/src/metta/runner/mod.rs +++ b/lib/src/metta/runner/mod.rs @@ -163,6 +163,11 @@ impl Metta { log::debug!("Metta::load_module_space: load module space {}", path.display()); let loaded_module = self.0.modules.borrow().get(&path).cloned(); + // TODO: This is a hack. We need a way to register tokens at module-load-time, for any module + if path.to_str().unwrap() == "stdlib" { + register_rust_tokens(self); + } + // Loading the module only once // TODO: force_reload? match loaded_module { @@ -184,11 +189,6 @@ impl Metta { runner.run(SExprParser::new(program.as_str())) .map_err(|err| format!("Cannot import module, path: {}, error: {}", path.display(), err))?; - // TODO: This is a hack. We need a way to register tokens at module-load-time, for any module - if path.to_str().unwrap() == "stdlib" { - register_rust_tokens(self); - } - Ok(runner.space().clone()) } } diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index 3f741443b..a142f1adf 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -1592,4 +1592,9 @@ mod tests { let result = GetStateOp{}.execute(&mut vec![new_state.clone()]); assert_eq!(result, Ok(vec![expr!("C" "D")])) } + + #[test] + fn test_stdlib_uses_rust_grounded_tokens() { + assert_eq!(run_program("!(if True ok nok)"), Ok(vec![vec![Atom::sym("ok")]])); + } }