Refactor: Simplify type checking context

The type checker's fallback logic for non-lambda nodes was unnecessarily
complex. This commit simplifies it by directly checking the node within
a new, basic type context.

Additionally, the environment now explicitly wraps non-lambda AST nodes
in a lambda before type checking, ensuring consistent handling. This
aligns the type checking process for all top-level expressions.
This commit is contained in:
Michael Schimmel
2026-03-06 23:19:52 +01:00
parent 84ef3f9aed
commit f797ac37bf
3 changed files with 59 additions and 31 deletions
+2 -16
View File
@@ -141,22 +141,8 @@ impl TypeChecker {
}
}
_ => {
// Fallback: Wrap in implicit lambda
let virtual_lambda = BoundNode {
identity: node.identity.clone(),
kind: BoundKind::Lambda {
params: Rc::new(Node {
identity: node.identity.clone(),
kind: BoundKind::Tuple { elements: vec![] },
ty: (),
}),
upvalues: vec![],
body: Rc::new(node.clone()),
positional_count: Some(0),
},
ty: (),
};
self.check(&virtual_lambda, &[], diag)
let mut root_ctx = TypeContext::new(0, vec![], &self.global_types, None);
self.check_node(node, &mut root_ctx, diag)
}
}
}