mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix printing struct having fields of arrays of anonymous structs (#16953)
This commit is contained in:
parent
41b9e513ca
commit
fd07f7df69
@ -2,7 +2,7 @@
|
||||
[vlib/v/checker/tests/comptime_dump_fields_var_test.vv:13] val.$field.name: d
|
||||
[vlib/v/checker/tests/comptime_dump_fields_var_test.vv:13] val.$field.name: 1
|
||||
[vlib/v/checker/tests/comptime_dump_fields_var_test.vv:13] val.$field.name: 0
|
||||
[vlib/v/checker/tests/comptime_dump_fields_var_test.vv:13] val.$field.name: _VAnonStruct1{
|
||||
[vlib/v/checker/tests/comptime_dump_fields_var_test.vv:13] val.$field.name: struct {
|
||||
i: 100
|
||||
}
|
||||
ok
|
||||
ok
|
||||
|
@ -829,7 +829,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, styp string, typ_str string,
|
||||
g.auto_fn_definitions << fn_builder.str()
|
||||
}
|
||||
fn_builder.writeln('static string indent_${str_fn_name}(${styp} it, int indent_count) {')
|
||||
clean_struct_v_type_name := util.strip_main_name(typ_str)
|
||||
clean_struct_v_type_name := if info.is_anon { 'struct ' } else { util.strip_main_name(typ_str) }
|
||||
// generate ident / indent length = 4 spaces
|
||||
if info.fields.len == 0 {
|
||||
fn_builder.writeln('\treturn _SLIT("${clean_struct_v_type_name}{}");')
|
||||
|
@ -0,0 +1,5 @@
|
||||
Abc{
|
||||
a: [struct {
|
||||
b: 'this is b'
|
||||
}]
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
struct Abc {
|
||||
a []struct {
|
||||
b string
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
abc := Abc{
|
||||
a: [struct {'this is b'}]
|
||||
}
|
||||
|
||||
println(abc)
|
||||
}
|
Loading…
Reference in New Issue
Block a user