mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: stringify multi-return types
This commit is contained in:
parent
2bbb8526a3
commit
87ad5a96b9
@ -103,3 +103,11 @@ const (
|
|||||||
'i128': true
|
'i128': true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fn fn_with_assign_stmts() {
|
||||||
|
a, b := fn_with_multi_return()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fn_with_multi_return() (int, string) {
|
||||||
|
return 0, 'test'
|
||||||
|
}
|
||||||
|
@ -107,3 +107,12 @@ reserved_types = {
|
|||||||
'i128': true
|
'i128': true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fn fn_with_assign_stmts() {
|
||||||
|
a,b := fn_with_multi_return()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fn_with_multi_return() (int,string) {
|
||||||
|
return 0,'test'
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
strings
|
strings
|
||||||
)
|
)
|
||||||
|
|
||||||
pub type TypeInfo = Array | ArrayFixed | Map | Struct |
|
pub type TypeInfo = Array | ArrayFixed | Map | Struct |
|
||||||
MultiReturn | Alias
|
MultiReturn | Alias
|
||||||
|
|
||||||
pub struct TypeSymbol {
|
pub struct TypeSymbol {
|
||||||
@ -399,6 +399,19 @@ pub mut:
|
|||||||
|
|
||||||
pub fn (table &Table) type_to_str(t Type) string {
|
pub fn (table &Table) type_to_str(t Type) string {
|
||||||
sym := table.get_type_symbol(t)
|
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_', '[]')
|
mut res := sym.name.replace('array_', '[]')
|
||||||
// mod.submod.submod2.Type => submod2.Type
|
// mod.submod.submod2.Type => submod2.Type
|
||||||
if res.contains('.') {
|
if res.contains('.') {
|
||||||
|
Loading…
Reference in New Issue
Block a user