mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check generic struct init using multi return type (#15472)
This commit is contained in:
parent
5cba5920d5
commit
0645fe3322
@ -675,6 +675,9 @@ pub fn (mut p Parser) parse_generic_inst_type(name string) ast.Type {
|
|||||||
is_instance = true
|
is_instance = true
|
||||||
}
|
}
|
||||||
gts := p.table.sym(gt)
|
gts := p.table.sym(gt)
|
||||||
|
if gts.kind == .multi_return {
|
||||||
|
p.error_with_pos('cannot use multi return as generic concrete type', type_pos)
|
||||||
|
}
|
||||||
if !is_instance && gts.name.len > 1 {
|
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('generic struct parameter name needs to be exactly one char',
|
||||||
type_pos)
|
type_pos)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/parser/tests/generic_struct_type_using_multi_return_err.vv:6:18: error: cannot use multi return as generic concrete type
|
||||||
|
4 |
|
||||||
|
5 | fn main() {
|
||||||
|
6 | sample := Tuple<(int, int)>{}
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
7 | println(sample)
|
||||||
|
8 | }
|
@ -0,0 +1,8 @@
|
|||||||
|
struct Tuple<T> {
|
||||||
|
data T
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
sample := Tuple<(int, int)>{}
|
||||||
|
println(sample)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user