Fix scope management issue when deep-inferring callee.

Fixes #941.

  However, this currently breaks the stdlib somehow with some FreeUnique on the shrinker step of the optimizer.
This commit is contained in:
KtorZ
2024-05-15 13:05:52 +02:00
parent b546e42766
commit eadf709411
4 changed files with 113 additions and 38 deletions

View File

@@ -2483,3 +2483,36 @@ fn not_indexable() {
Err((_, Error::NotIndexable { .. }))
))
}
#[test]
fn out_of_scope_access() {
let source_code = r#"
pub fn a(x: Int) {
b(x)
}
fn b(y: Int) {
x + y
}
"#;
assert!(matches!(
dbg!(check_validator(parse(source_code))),
Err((_, Error::UnknownVariable { .. }))
))
}
#[test]
fn mutually_recursive_1() {
let source_code = r#"
pub fn foo(x) {
bar(x)
}
pub fn bar(y) {
foo(y)
}
"#;
assert!(check(parse(source_code)).is_ok());
}