mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: improve error message for fn (a Foo<Foo<T>>) baz(){}
This commit is contained in:
parent
27d8f2371d
commit
056f1b7c06
@ -682,7 +682,7 @@ pub fn (mut p Parser) parse_generic_inst_type(name string) ast.Type {
|
||||
p.error_with_pos('cannot use multi return as generic concrete type', type_pos)
|
||||
}
|
||||
if !is_instance && gts.name.len > 1 {
|
||||
p.error_with_pos('generic struct parameter name needs to be exactly one char',
|
||||
p.error_with_pos('the parameter type name of a generic struct, must be a single capital letter placeholder name, like T or X, or a non-generic type name like int, string, etc.',
|
||||
type_pos)
|
||||
}
|
||||
bs_name += gts.name
|
||||
|
@ -1,4 +1,4 @@
|
||||
vlib/v/parser/tests/generic_struct_parameter_err.vv:10:17: error: generic struct parameter name needs to be exactly one char
|
||||
vlib/v/parser/tests/generic_struct_parameter_err.vv:10:17: error: the parameter type name of a generic struct, must be a single capital letter placeholder name, like T or X, or a non-generic type name like int, string, etc.
|
||||
8 | struct MyContainer<T> {
|
||||
9 | mut:
|
||||
10 | lst LinkedList<MyNode<T>>
|
||||
|
@ -0,0 +1,5 @@
|
||||
vlib/v/parser/tests/generic_struct_receiver_nested_generic_err.vv:5:11: error: the parameter type name of a generic struct, must be a single capital letter placeholder name, like T or X, or a non-generic type name like int, string, etc.
|
||||
3 | }
|
||||
4 |
|
||||
5 | fn (a Foo<Foo<T>>) baz() {}
|
||||
| ~~~~~~
|
@ -0,0 +1,5 @@
|
||||
struct Foo<T> {
|
||||
bar T
|
||||
}
|
||||
|
||||
fn (a Foo<Foo<T>>) baz() {}
|
Loading…
Reference in New Issue
Block a user