fix updated defs not being applied properly to VM in frontend and backend

this fixes the case where

	(def botsbuildbots (fn () (botsbuildbots))) (botsbuildbots)

would not run properly (return with a "set def index out of bounds" error)

also make exceptions store String instead of &'static str for better error reporting

closes #33
This commit is contained in:
りき萌 2024-08-22 17:50:44 +02:00
parent ccab723298
commit 3913254215
5 changed files with 27 additions and 8 deletions

View file

@ -167,6 +167,19 @@ fn def_mutually_recursive() {
expect_number(code, 14.0, 0.0001);
}
#[test]
fn def_botsbuildbots() {
let result = eval("(def botsbuildbots (fn () (botsbuildbots))) (botsbuildbots)");
if let Err(error) = result {
assert_eq!(
error.to_string(),
"Exception {\n message: \"too much recursion\",\n}"
);
} else {
panic!("error expected");
}
}
#[test]
fn let_single() {
let code = r#"