Use type definitions for type checks
This commit is contained in:
parent
4a42f51580
commit
f04adfc661
@ -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 {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user