🤔 Add a type inference engine, along with typed literals. #4
@@ -158,3 +158,19 @@ impl Expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cast_checks_are_reasonable() {
|
||||||
|
let good_stmt = Statement::parse(0, "x = <u16>4u8;").expect("valid test case");
|
||||||
|
let (good_errs, good_warns) = good_stmt.validate(&mut HashMap::new());
|
||||||
|
|
||||||
|
assert!(good_errs.is_empty());
|
||||||
|
assert!(good_warns.is_empty());
|
||||||
|
|
||||||
|
let bad_stmt = Statement::parse(0, "x = <apple>4u8;").expect("valid test case");
|
||||||
|
let (bad_errs, bad_warns) = bad_stmt.validate(&mut HashMap::new());
|
||||||
|
|
||||||
|
assert!(bad_warns.is_empty());
|
||||||
|
assert_eq!(bad_errs.len(), 1);
|
||||||
|
assert!(matches!(bad_errs[0], Error::UnknownType(_, ref x) if x == "apple"));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user