vfmt: fix deep nested map types, using f.table.type_to_str
parent
78bcda14c4
commit
1123f4fcc9
|
@ -590,7 +590,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
|
|||
if comments_len + field.name.len > max {
|
||||
max = comments_len + field.name.len
|
||||
}
|
||||
ft := f.type_to_str(field.typ)
|
||||
ft := f.table.type_to_str(field.typ)
|
||||
field_types << ft
|
||||
if ft.len > max_type {
|
||||
max_type = ft.len
|
||||
|
@ -886,18 +886,7 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
|
|||
}
|
||||
ast.MapInit {
|
||||
if node.keys.len == 0 {
|
||||
mut ktyp := node.key_type
|
||||
mut vtyp := node.value_type
|
||||
if vtyp == 0 {
|
||||
typ_sym := f.table.get_type_symbol(node.typ)
|
||||
minfo := typ_sym.info as table.Map
|
||||
ktyp = minfo.key_type
|
||||
vtyp = minfo.value_type
|
||||
}
|
||||
f.write('map[')
|
||||
f.write(f.type_to_str(ktyp))
|
||||
f.write(']')
|
||||
f.write(f.type_to_str(vtyp))
|
||||
f.write(f.table.type_to_str(node.typ))
|
||||
f.write('{}')
|
||||
return
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ struct Abcde {
|
|||
p4 []&Xyz
|
||||
p5 map[string]Xyz
|
||||
p6 map[string]&Xyz
|
||||
p7 map[string]map[string]map[string]&Xyz
|
||||
//
|
||||
p8 map[string]map[string]map[string]map[string]&Xyz
|
||||
p9 map[string]map[string]map[string]map[string]&vproto.Xyz
|
||||
}
|
||||
|
||||
fn abc() {
|
||||
|
@ -27,4 +31,5 @@ fn abc() {
|
|||
mut a := []vproto.Xyz{}
|
||||
a << x
|
||||
a << vproto.Xyz{3}
|
||||
z := map[string]map[string]map[string]map[string]&vproto.Xyz{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue