diff --git a/vlib/v/parser/parse_type.v b/vlib/v/parser/parse_type.v index 8cabef9025..5967014305 100644 --- a/vlib/v/parser/parse_type.v +++ b/vlib/v/parser/parse_type.v @@ -675,6 +675,9 @@ pub fn (mut p Parser) parse_generic_inst_type(name string) ast.Type { is_instance = true } 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 { p.error_with_pos('generic struct parameter name needs to be exactly one char', type_pos) diff --git a/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.out b/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.out new file mode 100644 index 0000000000..d04a63bae2 --- /dev/null +++ b/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.out @@ -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 | } diff --git a/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.vv b/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.vv new file mode 100644 index 0000000000..a04cc7d7d3 --- /dev/null +++ b/vlib/v/parser/tests/generic_struct_type_using_multi_return_err.vv @@ -0,0 +1,8 @@ +struct Tuple { + data T +} + +fn main() { + sample := Tuple<(int, int)>{} + println(sample) +}