Implement rudimentary type inference for unary operators

This commit is contained in:
Marcus Klaas de Vries
2019-01-14 23:15:16 +01:00
parent ab46f8abf1
commit a2b6d3da30
4 changed files with 72 additions and 5 deletions

View File

@@ -158,6 +158,29 @@ fn test() {
);
}
#[test]
fn infer_unary_op() {
check_inference(
r#"
enum SomeType {}
fn test(x: SomeType) {
let b = false;
let c = !b;
let a = 100;
let d: i128 = -a;
let e = -100;
let f = !!!true;
-3.14;
-x;
!x;
-"hello";
}
"#,
"unary_op.txt",
);
}
#[test]
fn infer_backwards() {
check_inference(