Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: show a more detailed error for invalid declarations of gener…
…ic methods on generic structs.
- Loading branch information
Showing
3 changed files
with
33 additions
and
9 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
21 changes: 15 additions & 6 deletions
21
vlib/v/checker/tests/generic_fn_decl_without_generic_names_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,15 +1,24 @@ | ||
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:26:1: error: generic function declaration must specify generic type names, e.g. foo<T> | ||
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:26:1: error: generic function declaration must specify generic type names | ||
24 | } | ||
25 | | ||
25 | | ||
26 | fn g_worker(g Generic<T>) { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
27 | t := <-g.ch | ||
28 | handle(t) | ||
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:1: error: generic function declaration must specify generic type names, e.g. foo<T> | ||
Details: use `fn foo<T>(x T) {`, not just `fn foo(x T) {` | ||
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:1: error: generic function declaration must specify generic type names | ||
30 | } | ||
31 | | ||
31 | | ||
32 | fn handle(t T) { | ||
| ~~~~~~~~~~~~~~ | ||
33 | println("hi") | ||
33 | println('hi') | ||
34 | } | ||
|
||
Details: use `fn foo<T>(x T) {`, not just `fn foo(x T) {` | ||
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:40:1: error: generic method declaration must specify generic type names | ||
38 | type MayBe<T> = None | T | ||
39 | | ||
40 | fn (m MayBe<T>) is_some() bool { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
41 | return m is T | ||
42 | } | ||
Details: use `fn (r SomeType<T>) foo<T>() {`, not just `fn (r SomeType<T>) foo() {` |
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