-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
53 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
vlib/v/checker/tests/generic_fn_decl_err.vv:19:29: error: generic type name `P` is not mentioned in fn `create1[U]` | ||
17 | } | ||
18 | | ||
19 | fn (r Db) create1<U>(u U, p P) { | ||
19 | fn (r Db) create1[U](u U, p P) { | ||
| ^ | ||
20 | println('Yo') | ||
21 | } | ||
vlib/v/checker/tests/generic_fn_decl_err.vv:23:29: error: generic type name `P` is not mentioned in fn `create2[U]` | ||
21 | } | ||
22 | | ||
23 | fn (r Db) create2<U>(u U, p &P) { | ||
23 | fn (r Db) create2[U](u U, p &P) { | ||
| ~~ | ||
24 | println('Yo') | ||
25 | } | ||
vlib/v/checker/tests/generic_fn_decl_err.vv:27:29: error: generic type name `P` is not mentioned in fn `create3[U]` | ||
25 | } | ||
26 | | ||
27 | fn (r Db) create3<U>(u U, p []P) { | ||
27 | fn (r Db) create3[U](u U, p []P) { | ||
| ~~~ | ||
28 | println('Yo') | ||
29 | } | ||
vlib/v/checker/tests/generic_fn_decl_err.vv:31:27: error: generic type name `P` is not mentioned in fn `create4[U]` | ||
29 | } | ||
30 | | ||
31 | fn (r Db) create4<U>(u U) P { | ||
31 | fn (r Db) create4[U](u U) P { | ||
| ^ | ||
32 | return P{} | ||
33 | } | ||
vlib/v/checker/tests/generic_fn_decl_err.vv:35:27: error: generic type name `P` is not mentioned in fn `create5[U]` | ||
33 | } | ||
34 | | ||
35 | fn (r Db) create5<U>(u U) []P { | ||
35 | fn (r Db) create5[U](u U) []P { | ||
| ~~~ | ||
36 | return [P{}] | ||
37 | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
vlib/v/checker/tests/generic_interface_method_decl_err.vv:2:8: error: no need to add generic type names in generic interface's method | ||
1 | interface Expr<R> { | ||
2 | accept<R>(v Visitor<R>) R | ||
1 | interface Expr[R] { | ||
2 | accept[R](v Visitor[R]) R | ||
| ^ | ||
3 | } | ||
4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
fn get_name<A, B>(a A, b B) string { | ||
fn get_name[A, B](a A, b B) string { | ||
return '$a, $b' | ||
} | ||
|
||
struct Foo {} | ||
|
||
fn (f Foo) get_name<A, B>(a A, b B) string { | ||
fn (f Foo) get_name[A, B](a A, b B) string { | ||
return '$a, $b' | ||
} | ||
|
||
fn main() { | ||
ret1 := get_name<int>(11, 22) | ||
ret1 := get_name[int](11, 22) | ||
println(ret1) | ||
|
||
ret2 := get_name<int, int, string>(11, 22, 'hello') | ||
ret2 := get_name[int, int, string](11, 22, 'hello') | ||
println(ret2) | ||
|
||
foo := Foo{} | ||
ret3 := foo.get_name<int>(11, 22) | ||
ret3 := foo.get_name[int](11, 22) | ||
println(ret3) | ||
|
||
ret4 := foo.get_name<int, int, string>(11, 22, 'hello') | ||
ret4 := foo.get_name[int, int, string](11, 22, 'hello') | ||
println(ret4) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
vlib/v/checker/tests/generics_inst_non_generic_struct_err.vv:5:14: error: struct `Test` is not a generic struct, cannot instantiate to the concrete types | ||
3 | | ||
4 | fn main() { | ||
5 | println(Test<string>{}) | ||
5 | println(Test[string]{}) | ||
| ~~~~~~~~ | ||
6 | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ struct Test { | |
} | ||
|
||
fn main() { | ||
println(Test<string>{}) | ||
println(Test[string]{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vlib/v/checker/tests/generics_interface_declaration_err.vv:1:1: error: generic interface `Expr` declaration must specify the generic type names, e.g. Expr[T] | ||
1 | interface Expr { | ||
| ~~~~~~~~~~~~~~~~ | ||
2 | accept(v Visitor<R>) R | ||
2 | accept(v Visitor[R]) R | ||
3 | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv:4:15: error: a non generic function called like a generic one | ||
2 | | ||
3 | fn main() { | ||
4 | x := math.sin<f64>(1.0) | ||
4 | x := math.sin[f64](1.0) | ||
| ~~~~~ | ||
5 | println(x) | ||
6 | } |
2 changes: 1 addition & 1 deletion
2
vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import math | ||
|
||
fn main() { | ||
x := math.sin<f64>(1.0) | ||
x := math.sin[f64](1.0) | ||
println(x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
vlib/v/checker/tests/generics_struct_init_type_parameter_err.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
vlib/v/checker/tests/generics_struct_init_type_parameter_err.vv:6:9: error: generic struct init type parameter `U` must be within the parameters `(A,B)` of the current generic function | ||
4 | | ||
5 | fn send_1<A, B>(res A, b B) string { | ||
6 | msg := Response<U>{ | ||
5 | fn send_1[A, B](res A, b B) string { | ||
6 | msg := Response[U]{ | ||
| ~~~~~~~~~~~~ | ||
7 | result: res | ||
8 | } | ||
vlib/v/checker/tests/generics_struct_init_type_parameter_err.vv:14:9: error: generic struct init expects 1 generic parameter, but got 2 | ||
12 | | ||
13 | fn send_2<A, B>(res A, b B) string { | ||
14 | msg := Response<A, B>{ | ||
13 | fn send_2[A, B](res A, b B) string { | ||
14 | msg := Response[A, B]{ | ||
| ~~~~~~~~~~~~~~~ | ||
15 | result: res | ||
16 | } |
10 changes: 5 additions & 5 deletions
10
vlib/v/checker/tests/generics_struct_init_type_parameter_err.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters