feat: Add type checking to the compiler
Introduces the `TypeChecker` struct and its associated `TypeContext` for performing static type analysis on the abstract syntax tree. This change includes: - A new `type_checker.rs` module. - Integration of `TypeChecker` into the `Environment::compile` method. - Updates to `Environment` to manage global types. - Renaming `bound_nodes.rs`'s `BoundNode` to `TypedNode` to reflect its type-checked nature. - Refinements in binder and macro expansion to accommodate type information.
This commit is contained in:
@@ -11,7 +11,7 @@ struct LocalInfo {
|
||||
// Note: Binder doesn't strictly need the type anymore,
|
||||
// but it might be useful for built-ins during resolution.
|
||||
// For now we keep it as Any or Unknown.
|
||||
ty: StaticType,
|
||||
_ty: StaticType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -33,7 +33,7 @@ impl CompilerScope {
|
||||
return Err(format!("Variable '{}' is already defined in this scope level.", sym.name));
|
||||
}
|
||||
let slot = self.slot_count;
|
||||
self.locals.insert(sym.clone(), LocalInfo { slot, ty: StaticType::Any });
|
||||
self.locals.insert(sym.clone(), LocalInfo { slot, _ty: StaticType::Any });
|
||||
self.slot_count += 1;
|
||||
Ok(slot)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user