1
0

Use type definitions for type checks

This commit is contained in:
Jeff 2024-01-17 14:50:39 -05:00
parent 4a42f51580
commit f04adfc661
2 changed files with 7 additions and 6 deletions

View File

@ -38,10 +38,13 @@ impl AbstractTree for Assignment {
let statement = Statement::from_syntax(statement_node, source, context)?; let statement = Statement::from_syntax(statement_node, source, context)?;
if let AssignmentOperator::Equal = operator { if let AssignmentOperator::Equal = operator {
context.set_type( let r#type = if let Some(definition) = &type_definition {
identifier.inner().clone(), definition.inner().clone()
statement.expected_type(context)?, } else {
)?; statement.expected_type(context)?
};
context.set_type(identifier.inner().clone(), r#type)?;
} }
Ok(Assignment { Ok(Assignment {

View File

@ -12,8 +12,6 @@ fn simple_type_check() {
#[test] #[test]
fn argument_count_check() { fn argument_count_check() {
env_logger::builder().is_test(true).try_init().unwrap();
let source = " let source = "
foo = (x <int>) <int> { foo = (x <int>) <int> {
x x