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)?;
if let AssignmentOperator::Equal = operator {
context.set_type(
identifier.inner().clone(),
statement.expected_type(context)?,
)?;
let r#type = if let Some(definition) = &type_definition {
definition.inner().clone()
} else {
statement.expected_type(context)?
};
context.set_type(identifier.inner().clone(), r#type)?;
}
Ok(Assignment {

View File

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