cgen: fix gen_str_for_struc when called on a struct with a pointer field

pull/4840/head
Ned Palacios 2020-05-11 16:08:21 +08:00 committed by GitHub
parent 1b3cd7abe0
commit 38277d1dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -3394,7 +3394,10 @@ fn (mut g Gen) gen_str_for_struct(info table.Struct, styp, str_fn_name string) {
sym := g.table.get_type_symbol(field.typ)
has_custom_str := sym.has_method('str')
second_str_param := if has_custom_str { '' } else { ', indent_count + 1' }
field_styp := g.typ(field.typ)
mut field_styp := g.typ(field.typ)
if field_styp.ends_with('*') {
field_styp = field_styp.replace('*', '')
}
field_styp_fn_name := if has_custom_str { '${field_styp}_str' } else { fnames2strfunc[field_styp] }
if sym.kind == .enum_ {
g.auto_str_funcs.write('indents, ')