[fine] More test more!

This commit is contained in:
John Doty 2024-01-15 07:19:29 -08:00
parent 2f8e1bad85
commit 257a7e64c2
2 changed files with 51 additions and 32 deletions

View file

@ -653,6 +653,7 @@ impl<'a> Semantics<'a> {
TreeKind::LetStatement => Some(Type::Nothing),
TreeKind::ReturnStatement => Some(Type::Unreachable),
TreeKind::ExpressionStatement => self.type_of_expression_statement(tree),
TreeKind::IfStatement => self.type_of_if_statement(tree),
TreeKind::Identifier => self.type_of_identifier(t, tree),
TreeKind::FunctionDecl => self.type_of_function_decl(tree),
@ -1020,6 +1021,10 @@ impl<'a> Semantics<'a> {
Some(Type::Function(parameter_types, return_type))
}
fn type_of_if_statement(&self, tree: &Tree) -> Option<Type> {
Some(self.type_of(tree.nth_tree(0)?))
}
pub fn dump_compiler_state(&self, tr: Option<TreeRef>) {
eprintln!("Parsed the tree as:");
eprintln!("\n{}", self.syntax_tree.dump(true));