Merge remote-tracking branch 'origin/trunk' into more-tea

This commit is contained in:
Richard Feldman 2020-12-13 22:50:10 -05:00
commit 860b120037
5 changed files with 871 additions and 167 deletions

View file

@ -742,51 +742,61 @@ define_builtins! {
1 NUM: "Num" => { 1 NUM: "Num" => {
0 NUM_NUM: "Num" imported // the Num.Num type alias 0 NUM_NUM: "Num" imported // the Num.Num type alias
1 NUM_AT_NUM: "@Num" // the Num.@Num private tag 1 NUM_AT_NUM: "@Num" // the Num.@Num private tag
2 NUM_I64: "I64" imported // the Num.I64 type alias 2 NUM_I128: "I128" imported // the Num.I128 type alias
3 NUM_INTEGER: "Integer" imported // Int : Num Integer 3 NUM_U128: "U128" imported // the Num.U128 type alias
4 NUM_AT_INTEGER: "@Integer" // the Int.@Integer private tag 4 NUM_I64: "I64" imported // the Num.I64 type alias
5 NUM_F64: "F64" imported // the Num.F64 type alias 5 NUM_U64: "U64" imported // the Num.U64 type alias
6 NUM_FLOATINGPOINT: "FloatingPoint" imported // Float : Num FloatingPoint 6 NUM_I32: "I32" imported // the Num.I32 type alias
7 NUM_AT_FLOATINGPOINT: "@FloatingPoint" // the Float.@FloatingPoint private tag 7 NUM_U32: "U32" imported // the Num.U32 type alias
8 NUM_MAX_INT: "maxInt" 8 NUM_I16: "I16" imported // the Num.I16 type alias
9 NUM_MIN_INT: "minInt" 9 NUM_U16: "U16" imported // the Num.U16 type alias
10 NUM_MAX_FLOAT: "maxFloat" 10 NUM_I8: "I8" imported // the Num.I8 type alias
11 NUM_MIN_FLOAT: "minFloat" 11 NUM_U8: "U8" imported // the Num.U8 type alias
12 NUM_ABS: "abs" 12 NUM_INTEGER: "Integer" imported // Int : Num Integer
13 NUM_NEG: "neg" 13 NUM_AT_INTEGER: "@Integer" // the Int.@Integer private tag
14 NUM_ADD: "add" 14 NUM_F64: "F64" imported // the Num.F64 type alias
15 NUM_SUB: "sub" 15 NUM_F32: "F32" imported // the Num.F32 type alias
16 NUM_MUL: "mul" 16 NUM_FLOATINGPOINT: "FloatingPoint" imported // Float : Num FloatingPoint
17 NUM_LT: "isLt" 17 NUM_AT_FLOATINGPOINT: "@FloatingPoint" // the Float.@FloatingPoint private tag
18 NUM_LTE: "isLte" 18 NUM_MAX_INT: "maxInt"
19 NUM_GT: "isGt" 19 NUM_MIN_INT: "minInt"
20 NUM_GTE: "isGte" 20 NUM_MAX_FLOAT: "maxFloat"
21 NUM_TO_FLOAT: "toFloat" 21 NUM_MIN_FLOAT: "minFloat"
22 NUM_SIN: "sin" 22 NUM_ABS: "abs"
23 NUM_COS: "cos" 23 NUM_NEG: "neg"
24 NUM_TAN: "tan" 24 NUM_ADD: "add"
25 NUM_IS_ZERO: "isZero" 25 NUM_SUB: "sub"
26 NUM_IS_EVEN: "isEven" 26 NUM_MUL: "mul"
27 NUM_IS_ODD: "isOdd" 27 NUM_LT: "isLt"
28 NUM_IS_POSITIVE: "isPositive" 28 NUM_LTE: "isLte"
29 NUM_IS_NEGATIVE: "isNegative" 29 NUM_GT: "isGt"
30 NUM_REM: "rem" 30 NUM_GTE: "isGte"
31 NUM_DIV_FLOAT: "div" 31 NUM_TO_FLOAT: "toFloat"
32 NUM_DIV_INT: "divFloor" 32 NUM_SIN: "sin"
33 NUM_MOD_INT: "modInt" 33 NUM_COS: "cos"
34 NUM_MOD_FLOAT: "modFloat" 34 NUM_TAN: "tan"
35 NUM_SQRT: "sqrt" 35 NUM_IS_ZERO: "isZero"
36 NUM_ROUND: "round" 36 NUM_IS_EVEN: "isEven"
37 NUM_COMPARE: "compare" 37 NUM_IS_ODD: "isOdd"
38 NUM_POW: "pow" 38 NUM_IS_POSITIVE: "isPositive"
39 NUM_CEILING: "ceiling" 39 NUM_IS_NEGATIVE: "isNegative"
40 NUM_POW_INT: "powInt" 40 NUM_REM: "rem"
41 NUM_FLOOR: "floor" 41 NUM_DIV_FLOAT: "div"
42 NUM_ADD_WRAP: "addWrap" 42 NUM_DIV_INT: "divFloor"
43 NUM_ADD_CHECKED: "addChecked" 43 NUM_MOD_INT: "modInt"
44 NUM_ATAN: "atan" 44 NUM_MOD_FLOAT: "modFloat"
45 NUM_ACOS: "acos" 45 NUM_SQRT: "sqrt"
46 NUM_ASIN: "asin" 46 NUM_ROUND: "round"
47 NUM_COMPARE: "compare"
48 NUM_POW: "pow"
49 NUM_CEILING: "ceiling"
50 NUM_POW_INT: "powInt"
51 NUM_FLOOR: "floor"
52 NUM_ADD_WRAP: "addWrap"
53 NUM_ADD_CHECKED: "addChecked"
54 NUM_ATAN: "atan"
55 NUM_ACOS: "acos"
56 NUM_ASIN: "asin"
} }
2 BOOL: "Bool" => { 2 BOOL: "Bool" => {
0 BOOL_BOOL: "Bool" imported // the Bool.Bool type alias 0 BOOL_BOOL: "Bool" imported // the Bool.Bool type alias

View file

@ -269,14 +269,14 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.4 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.4 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.4; ret Test.4;
procedure Test.0 (): procedure Test.0 ():
let Test.2 = 1i64; let Test.2 = 1i64;
let Test.3 = 2i64; let Test.3 = 2i64;
let Test.1 = CallByName Num.14 Test.2 Test.3; let Test.1 = CallByName Num.24 Test.2 Test.3;
ret Test.1; ret Test.1;
"# "#
), ),
@ -291,13 +291,13 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.36 (#Attr.2): procedure Num.46 (#Attr.2):
let Test.3 = lowlevel NumRound #Attr.2; let Test.3 = lowlevel NumRound #Attr.2;
ret Test.3; ret Test.3;
procedure Test.0 (): procedure Test.0 ():
let Test.2 = 3.6f64; let Test.2 = 3.6f64;
let Test.1 = CallByName Num.36 Test.2; let Test.1 = CallByName Num.46 Test.2;
ret Test.1; ret Test.1;
"# "#
), ),
@ -314,7 +314,7 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.32 (#Attr.2, #Attr.3): procedure Num.42 (#Attr.2, #Attr.3):
let Test.17 = 0i64; let Test.17 = 0i64;
let Test.13 = lowlevel NotEq #Attr.3 Test.17; let Test.13 = lowlevel NotEq #Attr.3 Test.17;
if Test.13 then if Test.13 then
@ -331,7 +331,7 @@ mod test_mono {
procedure Test.0 (): procedure Test.0 ():
let Test.8 = 1000i64; let Test.8 = 1000i64;
let Test.9 = 10i64; let Test.9 = 10i64;
let Test.2 = CallByName Num.32 Test.8 Test.9; let Test.2 = CallByName Num.42 Test.8 Test.9;
let Test.5 = 1i64; let Test.5 = 1i64;
let Test.6 = Index 0 Test.2; let Test.6 = Index 0 Test.2;
let Test.7 = lowlevel Eq Test.5 Test.6; let Test.7 = lowlevel Eq Test.5 Test.6;
@ -357,14 +357,14 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.4 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.4 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.4; ret Test.4;
procedure Test.0 (): procedure Test.0 ():
let Test.1 = 3i64; let Test.1 = 3i64;
let Test.2 = 4i64; let Test.2 = 4i64;
let Test.3 = CallByName Num.14 Test.1 Test.2; let Test.3 = CallByName Num.24 Test.1 Test.2;
ret Test.3; ret Test.3;
"# "#
), ),
@ -384,7 +384,7 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.5 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.5 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.5; ret Test.5;
@ -398,7 +398,7 @@ mod test_mono {
if Test.9 then if Test.9 then
let Test.2 = Index 1 Test.1; let Test.2 = Index 1 Test.1;
let Test.4 = 1i64; let Test.4 = 1i64;
let Test.3 = CallByName Num.14 Test.2 Test.4; let Test.3 = CallByName Num.24 Test.2 Test.4;
ret Test.3; ret Test.3;
else else
let Test.6 = 1i64; let Test.6 = 1i64;
@ -480,7 +480,7 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.5 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.5 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.5; ret Test.5;
@ -489,7 +489,7 @@ mod test_mono {
let Test.2 = Struct {Test.6}; let Test.2 = Struct {Test.6};
let Test.1 = Index 0 Test.2; let Test.1 = Index 0 Test.2;
let Test.4 = 3i64; let Test.4 = 3i64;
let Test.3 = CallByName Num.14 Test.1 Test.4; let Test.3 = CallByName Num.24 Test.1 Test.4;
ret Test.3; ret Test.3;
"# "#
), ),
@ -511,7 +511,7 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.6; ret Test.6;
@ -537,7 +537,7 @@ mod test_mono {
let Test.7 = Index 1 Test.2; let Test.7 = Index 1 Test.2;
let Test.3 = Index 1 Test.7; let Test.3 = Index 1 Test.7;
let Test.5 = 1i64; let Test.5 = 1i64;
let Test.4 = CallByName Num.14 Test.3 Test.5; let Test.4 = CallByName Num.24 Test.3 Test.5;
ret Test.4; ret Test.4;
else else
jump Test.14; jump Test.14;
@ -558,7 +558,7 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.6; ret Test.6;
@ -569,7 +569,7 @@ mod test_mono {
joinpoint Test.11: joinpoint Test.11:
let Test.1 = Index 0 Test.3; let Test.1 = Index 0 Test.3;
let Test.2 = Index 1 Test.3; let Test.2 = Index 1 Test.3;
let Test.5 = CallByName Num.14 Test.1 Test.2; let Test.5 = CallByName Num.24 Test.1 Test.2;
ret Test.5; ret Test.5;
in in
let Test.9 = Index 1 Test.3; let Test.9 = Index 1 Test.3;
@ -665,7 +665,7 @@ mod test_mono {
let Test.8 = lowlevel ListLen #Attr.2; let Test.8 = lowlevel ListLen #Attr.2;
ret Test.8; ret Test.8;
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.6; ret Test.6;
@ -680,7 +680,7 @@ mod test_mono {
dec Test.1; dec Test.1;
let Test.5 = CallByName List.7 Test.2; let Test.5 = CallByName List.7 Test.2;
dec Test.2; dec Test.2;
let Test.3 = CallByName Num.14 Test.4 Test.5; let Test.3 = CallByName Num.24 Test.4 Test.5;
ret Test.3; ret Test.3;
"# "#
), ),
@ -1055,14 +1055,14 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.8; ret Test.8;
procedure Test.1 (Test.2): procedure Test.1 (Test.2):
let Test.3 = Index 0 Test.2; let Test.3 = Index 0 Test.2;
let Test.4 = Index 1 Test.2; let Test.4 = Index 1 Test.2;
let Test.7 = CallByName Num.14 Test.3 Test.4; let Test.7 = CallByName Num.24 Test.3 Test.4;
ret Test.7; ret Test.7;
procedure Test.0 (): procedure Test.0 ():
@ -1091,14 +1091,14 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.8; ret Test.8;
procedure Test.1 (Test.2): procedure Test.1 (Test.2):
let Test.3 = 10i64; let Test.3 = 10i64;
let Test.4 = Index 1 Test.2; let Test.4 = Index 1 Test.2;
let Test.7 = CallByName Num.14 Test.3 Test.4; let Test.7 = CallByName Num.24 Test.3 Test.4;
ret Test.7; ret Test.7;
procedure Test.0 (): procedure Test.0 ():
@ -1124,14 +1124,14 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.8; ret Test.8;
procedure Test.1 (Test.4): procedure Test.1 (Test.4):
let Test.2 = Index 0 Test.4; let Test.2 = Index 0 Test.4;
let Test.3 = Index 1 Test.4; let Test.3 = Index 1 Test.4;
let Test.7 = CallByName Num.14 Test.2 Test.3; let Test.7 = CallByName Num.24 Test.2 Test.3;
ret Test.7; ret Test.7;
procedure Test.0 (): procedure Test.0 ():
@ -1158,14 +1158,14 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.8 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.8; ret Test.8;
procedure Test.1 (Test.4): procedure Test.1 (Test.4):
let Test.2 = 10i64; let Test.2 = 10i64;
let Test.3 = Index 1 Test.4; let Test.3 = Index 1 Test.4;
let Test.7 = CallByName Num.14 Test.2 Test.3; let Test.7 = CallByName Num.24 Test.2 Test.3;
ret Test.7; ret Test.7;
procedure Test.0 (): procedure Test.0 ():
@ -1496,11 +1496,11 @@ mod test_mono {
"#, "#,
indoc!( indoc!(
r#" r#"
procedure Num.15 (#Attr.2, #Attr.3): procedure Num.25 (#Attr.2, #Attr.3):
let Test.14 = lowlevel NumSub #Attr.2 #Attr.3; let Test.14 = lowlevel NumSub #Attr.2 #Attr.3;
ret Test.14; ret Test.14;
procedure Num.16 (#Attr.2, #Attr.3): procedure Num.26 (#Attr.2, #Attr.3):
let Test.12 = lowlevel NumMul #Attr.2 #Attr.3; let Test.12 = lowlevel NumMul #Attr.2 #Attr.3;
ret Test.12; ret Test.12;
@ -1512,8 +1512,8 @@ mod test_mono {
ret Test.3; ret Test.3;
else else
let Test.13 = 1i64; let Test.13 = 1i64;
let Test.10 = CallByName Num.15 Test.2 Test.13; let Test.10 = CallByName Num.25 Test.2 Test.13;
let Test.11 = CallByName Num.16 Test.2 Test.3; let Test.11 = CallByName Num.26 Test.2 Test.3;
jump Test.7 Test.10 Test.11; jump Test.7 Test.10 Test.11;
in in
jump Test.7 Test.2 Test.3; jump Test.7 Test.2 Test.3;
@ -1715,7 +1715,7 @@ mod test_mono {
let Test.9 = lowlevel ListLen #Attr.2; let Test.9 = lowlevel ListLen #Attr.2;
ret Test.9; ret Test.9;
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.7 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.7 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.7; ret Test.7;
@ -1740,7 +1740,7 @@ mod test_mono {
let Test.8 = FunctionPointer Test.1; let Test.8 = FunctionPointer Test.1;
let Test.6 = CallByName List.7 Test.8; let Test.6 = CallByName List.7 Test.8;
dec Test.8; dec Test.8;
let Test.4 = CallByName Num.14 Test.5 Test.6; let Test.4 = CallByName Num.24 Test.5 Test.6;
ret Test.4; ret Test.4;
"# "#
), ),
@ -1935,7 +1935,7 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.16 (#Attr.2, #Attr.3): procedure Num.26 (#Attr.2, #Attr.3):
let Test.13 = lowlevel NumMul #Attr.2 #Attr.3; let Test.13 = lowlevel NumMul #Attr.2 #Attr.3;
ret Test.13; ret Test.13;
@ -1976,9 +1976,9 @@ mod test_mono {
let Test.22 = false; let Test.22 = false;
let Test.15 = Struct {Test.21, Test.22}; let Test.15 = Struct {Test.21, Test.22};
let Test.2 = CallByName Test.1 Test.15; let Test.2 = CallByName Test.1 Test.15;
let Test.14 = CallByName Num.16 Test.2 Test.3; let Test.14 = CallByName Num.26 Test.2 Test.3;
let Test.12 = CallByName Num.16 Test.14 Test.4; let Test.12 = CallByName Num.26 Test.14 Test.4;
let Test.11 = CallByName Num.16 Test.12 Test.5; let Test.11 = CallByName Num.26 Test.12 Test.5;
ret Test.11; ret Test.11;
"# "#
), ),
@ -2002,7 +2002,7 @@ mod test_mono {
), ),
indoc!( indoc!(
r#" r#"
procedure Num.14 (#Attr.2, #Attr.3): procedure Num.24 (#Attr.2, #Attr.3):
let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3; let Test.6 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Test.6; ret Test.6;
@ -2028,7 +2028,7 @@ mod test_mono {
let Test.7 = Index 1 Test.2; let Test.7 = Index 1 Test.2;
let Test.3 = Index 1 Test.7; let Test.3 = Index 1 Test.7;
let Test.5 = 1i64; let Test.5 = 1i64;
let Test.4 = CallByName Num.14 Test.3 Test.5; let Test.4 = CallByName Num.24 Test.3 Test.5;
ret Test.4; ret Test.4;
else else
jump Test.14; jump Test.14;

View file

@ -449,7 +449,7 @@ mod test_reporting {
baz baz
Str Str
main main
F64 U8
"# "#
), ),
) )
@ -623,7 +623,7 @@ mod test_reporting {
Num Num
Set Set
Result Result
F64 U8
"# "#
), ),
); );
@ -1372,9 +1372,9 @@ mod test_reporting {
these names seem close though: these names seem close though:
Bool Bool
U8
F64 F64
Num Num
Set
"# "#
), ),
) )
@ -1827,10 +1827,10 @@ mod test_reporting {
these names seem close though: these names seem close though:
U8
f f
I8
F64 F64
Num
Set
"# "#
), ),
) )

View file

@ -1322,21 +1322,7 @@ mod solve_expr {
} }
#[test] #[test]
fn annotation_using_int() { fn qualified_annotation_num_integer() {
infer_eq(
indoc!(
r#"
int : I64
int
"#
),
"I64",
);
}
#[test]
fn annotation_using_num_integer() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
@ -1348,13 +1334,12 @@ mod solve_expr {
"I64", "I64",
); );
} }
#[test] #[test]
fn annotated_int() { fn qualified_annotated_num_integer() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
int : I64 int : Num.Num Num.Integer
int = 5 int = 5
int int
@ -1363,14 +1348,12 @@ mod solve_expr {
"I64", "I64",
); );
} }
#[test] #[test]
fn qualified_annotated_int() { fn annotation_num_integer() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
int : Num.I64 int : Num Integer
int = 5
int int
"# "#
@ -1378,7 +1361,6 @@ mod solve_expr {
"I64", "I64",
); );
} }
#[test] #[test]
fn annotated_num_integer() { fn annotated_num_integer() {
infer_eq( infer_eq(
@ -1395,14 +1377,164 @@ mod solve_expr {
} }
#[test] #[test]
fn qualified_annotated_num_integer() { fn qualified_annotation_using_i128() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
int : Num.Num Num.Integer int : Num.I128
int = 5
int int
"#
),
"I128",
);
}
#[test]
fn qualified_annotated_using_i128() {
infer_eq(
indoc!(
r#"
int : Num.I128
int = 5
int
"#
),
"I128",
);
}
#[test]
fn annotation_using_i128() {
infer_eq(
indoc!(
r#"
int : I128
int
"#
),
"I128",
);
}
#[test]
fn annotated_using_i128() {
infer_eq(
indoc!(
r#"
int : I128
int = 5
int
"#
),
"I128",
);
}
#[test]
fn qualified_annotation_using_u128() {
infer_eq(
indoc!(
r#"
int : Num.U128
int
"#
),
"U128",
);
}
#[test]
fn qualified_annotated_using_u128() {
infer_eq(
indoc!(
r#"
int : Num.U128
int = 5
int
"#
),
"U128",
);
}
#[test]
fn annotation_using_u128() {
infer_eq(
indoc!(
r#"
int : U128
int
"#
),
"U128",
);
}
#[test]
fn annotated_using_u128() {
infer_eq(
indoc!(
r#"
int : U128
int = 5
int
"#
),
"U128",
);
}
#[test]
fn qualified_annotation_using_i64() {
infer_eq(
indoc!(
r#"
int : Num.I64
int
"#
),
"I64",
);
}
#[test]
fn qualified_annotated_using_i64() {
infer_eq(
indoc!(
r#"
int : Num.I64
int = 5
int
"#
),
"I64",
);
}
#[test]
fn annotation_using_i64() {
infer_eq(
indoc!(
r#"
int : I64
int
"#
),
"I64",
);
}
#[test]
fn annotated_using_i64() {
infer_eq(
indoc!(
r#"
int : I64
int = 5
int
"# "#
), ),
"I64", "I64",
@ -1410,11 +1542,396 @@ mod solve_expr {
} }
#[test] #[test]
fn annotation_using_float() { fn qualified_annotation_using_u64() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
float : F64 int : Num.U64
int
"#
),
"U64",
);
}
#[test]
fn qualified_annotated_using_u64() {
infer_eq(
indoc!(
r#"
int : Num.U64
int = 5
int
"#
),
"U64",
);
}
#[test]
fn annotation_using_u64() {
infer_eq(
indoc!(
r#"
int : U64
int
"#
),
"U64",
);
}
#[test]
fn annotated_using_u64() {
infer_eq(
indoc!(
r#"
int : U64
int = 5
int
"#
),
"U64",
);
}
#[test]
fn qualified_annotation_using_i32() {
infer_eq(
indoc!(
r#"
int : Num.I32
int
"#
),
"I32",
);
}
#[test]
fn qualified_annotated_using_i32() {
infer_eq(
indoc!(
r#"
int : Num.I32
int = 5
int
"#
),
"I32",
);
}
#[test]
fn annotation_using_i32() {
infer_eq(
indoc!(
r#"
int : I32
int
"#
),
"I32",
);
}
#[test]
fn annotated_using_i32() {
infer_eq(
indoc!(
r#"
int : I32
int = 5
int
"#
),
"I32",
);
}
#[test]
fn qualified_annotation_using_u32() {
infer_eq(
indoc!(
r#"
int : Num.U32
int
"#
),
"U32",
);
}
#[test]
fn qualified_annotated_using_u32() {
infer_eq(
indoc!(
r#"
int : Num.U32
int = 5
int
"#
),
"U32",
);
}
#[test]
fn annotation_using_u32() {
infer_eq(
indoc!(
r#"
int : U32
int
"#
),
"U32",
);
}
#[test]
fn annotated_using_u32() {
infer_eq(
indoc!(
r#"
int : U32
int = 5
int
"#
),
"U32",
);
}
#[test]
fn qualified_annotation_using_i16() {
infer_eq(
indoc!(
r#"
int : Num.I16
int
"#
),
"I16",
);
}
#[test]
fn qualified_annotated_using_i16() {
infer_eq(
indoc!(
r#"
int : Num.I16
int = 5
int
"#
),
"I16",
);
}
#[test]
fn annotation_using_i16() {
infer_eq(
indoc!(
r#"
int : I16
int
"#
),
"I16",
);
}
#[test]
fn annotated_using_i16() {
infer_eq(
indoc!(
r#"
int : I16
int = 5
int
"#
),
"I16",
);
}
#[test]
fn qualified_annotation_using_u16() {
infer_eq(
indoc!(
r#"
int : Num.U16
int
"#
),
"U16",
);
}
#[test]
fn qualified_annotated_using_u16() {
infer_eq(
indoc!(
r#"
int : Num.U16
int = 5
int
"#
),
"U16",
);
}
#[test]
fn annotation_using_u16() {
infer_eq(
indoc!(
r#"
int : U16
int
"#
),
"U16",
);
}
#[test]
fn annotated_using_u16() {
infer_eq(
indoc!(
r#"
int : U16
int = 5
int
"#
),
"U16",
);
}
#[test]
fn qualified_annotation_using_i8() {
infer_eq(
indoc!(
r#"
int : Num.I8
int
"#
),
"I8",
);
}
#[test]
fn qualified_annotated_using_i8() {
infer_eq(
indoc!(
r#"
int : Num.I8
int = 5
int
"#
),
"I8",
);
}
#[test]
fn annotation_using_i8() {
infer_eq(
indoc!(
r#"
int : I8
int
"#
),
"I8",
);
}
#[test]
fn annotated_using_i8() {
infer_eq(
indoc!(
r#"
int : I8
int = 5
int
"#
),
"I8",
);
}
#[test]
fn qualified_annotation_using_u8() {
infer_eq(
indoc!(
r#"
int : Num.U8
int
"#
),
"U8",
);
}
#[test]
fn qualified_annotated_using_u8() {
infer_eq(
indoc!(
r#"
int : Num.U8
int = 5
int
"#
),
"U8",
);
}
#[test]
fn annotation_using_u8() {
infer_eq(
indoc!(
r#"
int : U8
int
"#
),
"U8",
);
}
#[test]
fn annotated_using_u8() {
infer_eq(
indoc!(
r#"
int : U8
int = 5
int
"#
),
"U8",
);
}
#[test]
fn qualified_annotation_num_floatingpoint() {
infer_eq(
indoc!(
r#"
float : Num.Num Num.FloatingPoint
float float
"# "#
@ -1422,9 +1939,22 @@ mod solve_expr {
"F64", "F64",
); );
} }
#[test] #[test]
fn annotation_using_num_floatingpoint() { fn qualified_annotated_num_floatingpoint() {
infer_eq(
indoc!(
r#"
float : Num.Num Num.FloatingPoint
float = 5.5
float
"#
),
"F64",
);
}
#[test]
fn annotation_num_floatingpoint() {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
@ -1436,37 +1966,6 @@ mod solve_expr {
"F64", "F64",
); );
} }
#[test]
fn qualified_annotated_float() {
infer_eq(
indoc!(
r#"
float : Num.F64
float = 5.5
float
"#
),
"F64",
);
}
#[test]
fn annotated_float() {
infer_eq(
indoc!(
r#"
float : F64
float = 5.5
float
"#
),
"F64",
);
}
#[test] #[test]
fn annotated_num_floatingpoint() { fn annotated_num_floatingpoint() {
infer_eq( infer_eq(
@ -1482,6 +1981,116 @@ mod solve_expr {
); );
} }
#[test]
fn qualified_annotation_f64() {
infer_eq(
indoc!(
r#"
float : Num.F64
float
"#
),
"F64",
);
}
#[test]
fn qualified_annotated_f64() {
infer_eq(
indoc!(
r#"
float : Num.F64
float = 5.5
float
"#
),
"F64",
);
}
#[test]
fn annotation_f64() {
infer_eq(
indoc!(
r#"
float : F64
float
"#
),
"F64",
);
}
#[test]
fn annotated_f64() {
infer_eq(
indoc!(
r#"
float : F64
float = 5.5
float
"#
),
"F64",
);
}
#[test]
fn qualified_annotation_f32() {
infer_eq(
indoc!(
r#"
float : Num.F32
float
"#
),
"F32",
);
}
#[test]
fn qualified_annotated_f32() {
infer_eq(
indoc!(
r#"
float : Num.F32
float = 5.5
float
"#
),
"F32",
);
}
#[test]
fn annotation_f32() {
infer_eq(
indoc!(
r#"
float : F32
float
"#
),
"F32",
);
}
#[test]
fn annotated_f32() {
infer_eq(
indoc!(
r#"
float : F32
float = 5.5
float
"#
),
"F32",
);
}
#[test] #[test]
fn fake_result_ok() { fn fake_result_ok() {
infer_eq( infer_eq(
@ -1567,21 +2176,6 @@ mod solve_expr {
); );
} }
#[test]
fn qualified_annotated_num_floatingpoint() {
infer_eq(
indoc!(
r#"
float : Num.Num Num.FloatingPoint
float = 5.5
float
"#
),
"F64",
);
}
// #[test] // #[test]
// fn annotation_using_num_used() { // fn annotation_using_num_used() {
// // There was a problem where `I64`, because it is only an annotation // // There was a problem where `I64`, because it is only an annotation

View file

@ -48,7 +48,27 @@ pub fn aliases() -> MutMap<Symbol, BuiltinAlias> {
}, },
); );
// Int : Num Integer // I128 Num Integer
add_alias(
Symbol::NUM_I128,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// U128 : Num Integer
add_alias(
Symbol::NUM_U128,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// I64 Num Integer
add_alias( add_alias(
Symbol::NUM_I64, Symbol::NUM_I64,
BuiltinAlias { BuiltinAlias {
@ -58,6 +78,76 @@ pub fn aliases() -> MutMap<Symbol, BuiltinAlias> {
}, },
); );
// U64 : Num Integer
add_alias(
Symbol::NUM_U64,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// I32 Num Integer
add_alias(
Symbol::NUM_I32,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// U32 : Num Integer
add_alias(
Symbol::NUM_U32,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// I16 Num Integer
add_alias(
Symbol::NUM_I16,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// U16 : Num Integer
add_alias(
Symbol::NUM_U16,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// I8 Num Integer
add_alias(
Symbol::NUM_I8,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// U8 : Num Integer
add_alias(
Symbol::NUM_U8,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: int_alias_content(),
},
);
// FloatingPoint : [ @FloatingPoint ] // FloatingPoint : [ @FloatingPoint ]
add_alias( add_alias(
Symbol::NUM_FLOATINGPOINT, Symbol::NUM_FLOATINGPOINT,
@ -68,7 +158,7 @@ pub fn aliases() -> MutMap<Symbol, BuiltinAlias> {
}, },
); );
// Float : Num FloatingPoint // F64 : Num FloatingPoint
add_alias( add_alias(
Symbol::NUM_F64, Symbol::NUM_F64,
BuiltinAlias { BuiltinAlias {
@ -78,6 +168,16 @@ pub fn aliases() -> MutMap<Symbol, BuiltinAlias> {
}, },
); );
// F32 : Num FloatingPoint
add_alias(
Symbol::NUM_F32,
BuiltinAlias {
region: Region::zero(),
vars: Vec::new(),
typ: float_alias_content(),
},
);
// Bool : [ True, False ] // Bool : [ True, False ]
add_alias( add_alias(
Symbol::BOOL_BOOL, Symbol::BOOL_BOOL,