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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user