mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
Start typechecking generics
This commit is contained in:
parent
bf73203182
commit
01d4238269
15 changed files with 248 additions and 19 deletions
3
ui-tests/type/generics/generics_on_primitive.nil
Normal file
3
ui-tests/type/generics/generics_on_primitive.nil
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function main() = (
|
||||
let a: I32[I32] = 0;
|
||||
);
|
||||
4
ui-tests/type/generics/generics_on_primitive.stderr
Normal file
4
ui-tests/type/generics/generics_on_primitive.stderr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
error: type I32 does not take generic arguments
|
||||
--> $DIR/generics_on_primitive.nil:2
|
||||
2 | let a: I32[I32] = 0;
|
||||
^^^
|
||||
8
ui-tests/type/generics/structs.nil
Normal file
8
ui-tests/type/generics/structs.nil
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
type A[T] = struct { a: T };
|
||||
type B[T, U, V] = struct {
|
||||
b: T,
|
||||
d: V,
|
||||
};
|
||||
type C = ();
|
||||
|
||||
function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
4
ui-tests/type/generics/structs.stderr
Normal file
4
ui-tests/type/generics/structs.stderr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
error: `main` function not found
|
||||
--> $DIR/structs.nil:1
|
||||
1 | type A[T] = struct { a: T };
|
||||
^
|
||||
23
ui-tests/type/generics/wrong_amount.nil
Normal file
23
ui-tests/type/generics/wrong_amount.nil
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
type A[T] = struct { a: T };
|
||||
type B[T, U, V] = struct {
|
||||
b: T,
|
||||
d: V,
|
||||
};
|
||||
type C = ();
|
||||
|
||||
function test(
|
||||
a1: A,
|
||||
a2: A[],
|
||||
a3: A[I32],
|
||||
a4: A[I32, I32],
|
||||
|
||||
b1: B,
|
||||
b2: B[],
|
||||
b3: B[Int, Int],
|
||||
b4: B[Int, I32, Int],
|
||||
b5: B[Int, Int, Int, Int],
|
||||
|
||||
c1: C,
|
||||
c2: C[],
|
||||
c3: C[I32],
|
||||
) = ;
|
||||
36
ui-tests/type/generics/wrong_amount.stderr
Normal file
36
ui-tests/type/generics/wrong_amount.stderr
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
error: expected 1 generic arguments, found 0
|
||||
--> $DIR/wrong_amount.nil:9
|
||||
9 | a1: A,
|
||||
^
|
||||
error: expected 1 generic arguments, found 0
|
||||
--> $DIR/wrong_amount.nil:10
|
||||
10 | a2: A[],
|
||||
^
|
||||
error: expected 1 generic arguments, found 2
|
||||
--> $DIR/wrong_amount.nil:12
|
||||
12 | a4: A[I32, I32],
|
||||
^
|
||||
error: expected 3 generic arguments, found 0
|
||||
--> $DIR/wrong_amount.nil:14
|
||||
14 | b1: B,
|
||||
^
|
||||
error: expected 3 generic arguments, found 0
|
||||
--> $DIR/wrong_amount.nil:15
|
||||
15 | b2: B[],
|
||||
^
|
||||
error: expected 3 generic arguments, found 2
|
||||
--> $DIR/wrong_amount.nil:16
|
||||
16 | b3: B[Int, Int],
|
||||
^
|
||||
error: expected 3 generic arguments, found 4
|
||||
--> $DIR/wrong_amount.nil:18
|
||||
18 | b5: B[Int, Int, Int, Int],
|
||||
^
|
||||
error: type () does not take generic arguments
|
||||
--> $DIR/wrong_amount.nil:22
|
||||
22 | c3: C[I32],
|
||||
^
|
||||
error: `main` function not found
|
||||
--> $DIR/wrong_amount.nil:1
|
||||
1 | type A[T] = struct { a: T };
|
||||
^
|
||||
Loading…
Add table
Add a link
Reference in a new issue