Add type checks for maps
This commit is contained in:
parent
d2dcc665bb
commit
afa937a697
@ -128,6 +128,10 @@ impl AbstractTree for ValueNode {
|
|||||||
let statement =
|
let statement =
|
||||||
Statement::from_syntax_node(source, child_syntax_node, context)?;
|
Statement::from_syntax_node(source, child_syntax_node, context)?;
|
||||||
|
|
||||||
|
if let Some(type_definition) = ¤t_type {
|
||||||
|
type_definition.check(&statement.expected_type(context)?)?;
|
||||||
|
}
|
||||||
|
|
||||||
child_nodes.insert(current_key.clone(), (statement, current_type.clone()));
|
child_nodes.insert(current_key.clone(), (statement, current_type.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,6 +304,16 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn evaluate_map_type_errors() {
|
||||||
|
assert!(evaluate("{ foo <bool> = 'bar' }")
|
||||||
|
.unwrap_err()
|
||||||
|
.is_type_check_error(&Error::TypeCheck {
|
||||||
|
expected: Type::Boolean,
|
||||||
|
actual: Type::String
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn evaluate_function() {
|
fn evaluate_function() {
|
||||||
let result = evaluate("(fn) <int> { 1 }");
|
let result = evaluate("(fn) <int> { 1 }");
|
||||||
|
Loading…
Reference in New Issue
Block a user