-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: optimize error messages for must specify the generic type na…
- Loading branch information
Showing
3 changed files
with
28 additions
and
10 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
17 changes: 12 additions & 5 deletions
17
vlib/v/checker/tests/generics_method_receiver_type_err_b.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,14 @@ | ||
vlib/v/checker/tests/generics_method_receiver_type_err_b.vv:8:12: error: generic struct `ConsumableResources` in fn declaration must specify the generic type names, e.g. ConsumableResources[T] | ||
6 | used_resources map[T]Resources | ||
vlib/v/checker/tests/generics_method_receiver_type_err_b.vv:9:12: error: generic struct `ConsumableResources` in fn declaration must specify the generic type names, e.g. ConsumableResources[T] | ||
7 | } | ||
8 | pub fn (cr &ConsumableResources) get_total_resources() Resources { | ||
8 | | ||
9 | pub fn (cr &ConsumableResources) get_total_resources() Resources { | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
9 | return cr.total_resources | ||
10 | } | ||
10 | return cr.total_resources | ||
11 | } | ||
vlib/v/checker/tests/generics_method_receiver_type_err_b.vv:19:11: error: generic struct `Foo` in fn declaration must specify the generic type names, e.g. Foo[T] | ||
17 | } | ||
18 | | ||
19 | pub fn (f Foo) method() { | ||
| ~~~ | ||
20 | } | ||
21 | |
14 changes: 12 additions & 2 deletions
14
vlib/v/checker/tests/generics_method_receiver_type_err_b.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,13 +1,23 @@ | ||
pub struct Resources{} | ||
pub struct Resources {} | ||
|
||
pub struct ConsumableResources[T] { | ||
mut: | ||
total_resources Resources | ||
used_resources map[T]Resources | ||
used_resources map[T]Resources | ||
} | ||
|
||
pub fn (cr &ConsumableResources) get_total_resources() Resources { | ||
return cr.total_resources | ||
} | ||
|
||
// for issue 20362 | ||
struct Foo[T] {} | ||
|
||
pub fn new_foo[F](arg F) !Foo[F] { | ||
} | ||
|
||
pub fn (f Foo) method() { | ||
} | ||
|
||
fn main() { | ||
} |