diff --git a/vlib/v/fmt/tests/simple_expected.vv b/vlib/v/fmt/tests/simple_expected.vv index afaa6fd48f..08564e8cb3 100644 --- a/vlib/v/fmt/tests/simple_expected.vv +++ b/vlib/v/fmt/tests/simple_expected.vv @@ -103,3 +103,11 @@ const ( 'i128': true } ) + +fn fn_with_assign_stmts() { + a, b := fn_with_multi_return() +} + +fn fn_with_multi_return() (int, string) { + return 0, 'test' +} diff --git a/vlib/v/fmt/tests/simple_input.vv b/vlib/v/fmt/tests/simple_input.vv index 72df4137c1..72969af6f4 100644 --- a/vlib/v/fmt/tests/simple_input.vv +++ b/vlib/v/fmt/tests/simple_input.vv @@ -107,3 +107,12 @@ reserved_types = { 'i128': true } ) + +fn fn_with_assign_stmts() { + a,b := fn_with_multi_return() +} + +fn fn_with_multi_return() (int,string) { + return 0,'test' +} + diff --git a/vlib/v/table/atype_symbols.v b/vlib/v/table/atype_symbols.v index 64d9423321..d09654b839 100644 --- a/vlib/v/table/atype_symbols.v +++ b/vlib/v/table/atype_symbols.v @@ -7,7 +7,7 @@ import ( strings ) -pub type TypeInfo = Array | ArrayFixed | Map | Struct | +pub type TypeInfo = Array | ArrayFixed | Map | Struct | MultiReturn | Alias pub struct TypeSymbol { @@ -399,6 +399,19 @@ pub mut: pub fn (table &Table) type_to_str(t Type) string { sym := table.get_type_symbol(t) + if sym.kind == .multi_return { + mut res := '(' + mr_info := sym.info as MultiReturn + for i, typ in mr_info.types { + res += table.type_to_str(typ) + if i < mr_info.types.len - 1 { + res += ', ' + } + } + res += ')' + return res + } + mut res := sym.name.replace('array_', '[]') // mod.submod.submod2.Type => submod2.Type if res.contains('.') {