1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix error priting struct which has .str already

This commit is contained in:
Daniel Däschle 2020-04-12 15:25:02 +02:00 committed by GitHub
parent 5818956cdc
commit d55f4ab097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3207,7 +3207,8 @@ fn (g mut Gen) gen_str_for_struct(info table.Struct, styp string) {
sym := g.table.get_type_symbol(field.typ)
if sym.kind == .struct_ {
field_styp := g.typ(field.typ)
g.definitions.write('indents.len, indents.str, ${field_styp}_str(it.$field.name, indent_count + 1).len, ${field_styp}_str(it.$field.name, indent_count + 1).str')
second_str_param := if sym.has_method('str') { '' } else { ', indent_count + 1' }
g.definitions.write('indents.len, indents.str, ${field_styp}_str(it.$field.name$second_str_param).len, ${field_styp}_str(it.$field.name$second_str_param).str')
} else {
g.definitions.write('indents.len, indents.str, it.$field.name')
if field.typ == table.string_type {
@ -3215,9 +3216,9 @@ fn (g mut Gen) gen_str_for_struct(info table.Struct, styp string) {
} else if field.typ == table.bool_type {
g.definitions.write(' ? 4 : 5, it.${field.name} ? "true" : "false"')
}
if i < info.fields.len - 1 {
g.definitions.write(', ')
}
}
if i < info.fields.len - 1 {
g.definitions.write(', ')
}
}
}