vfmt: fix table.type_to_str(), keep map[string]mod.Type in fn args

pull/5331/head
Delyan Angelov 2020-06-10 17:12:55 +03:00
parent acf0b84523
commit 3a369f513c
1 changed files with 5 additions and 0 deletions

View File

@ -700,8 +700,10 @@ pub fn (table &Table) type_to_str(t Type) string {
if sym.kind == .array || 'array_' in res { if sym.kind == .array || 'array_' in res {
res = res.replace('array_', '[]') res = res.replace('array_', '[]')
} }
mut map_start := ''
if sym.kind == .map || 'map_string_' in res { if sym.kind == .map || 'map_string_' in res {
res = res.replace('map_string_', 'map[string]') res = res.replace('map_string_', 'map[string]')
map_start = 'map[string]'
} }
// mod.submod.submod2.Type => submod2.Type // mod.submod.submod2.Type => submod2.Type
if res.contains('.') { if res.contains('.') {
@ -712,6 +714,9 @@ pub fn (table &Table) type_to_str(t Type) string {
if sym.kind == .array && !res.starts_with('[]') { if sym.kind == .array && !res.starts_with('[]') {
res = '[]' + res res = '[]' + res
} }
if sym.kind == .map && !res.starts_with('map') {
res = map_start + res
}
} }
nr_muls := t.nr_muls() nr_muls := t.nr_muls()
if nr_muls > 0 { if nr_muls > 0 {