diff --git a/vlib/v/checker/tests/comptime_dump_fields_var_test.out b/vlib/v/checker/tests/comptime_dump_fields_var_test.out index ce67fd3b2c..ce59179bc7 100644 --- a/vlib/v/checker/tests/comptime_dump_fields_var_test.out +++ b/vlib/v/checker/tests/comptime_dump_fields_var_test.out @@ -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 \ No newline at end of file +ok diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index d336ee6c96..41031be223 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -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}{}");') diff --git a/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.out b/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.out new file mode 100644 index 0000000000..c9a430d5d5 --- /dev/null +++ b/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.out @@ -0,0 +1,5 @@ +Abc{ + a: [struct { + b: 'this is b' + }] +} diff --git a/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.vv b/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.vv new file mode 100644 index 0000000000..fa2b7d494c --- /dev/null +++ b/vlib/v/slow_tests/inout/printing_struct_with_arrays_of_anon_struct_field.vv @@ -0,0 +1,13 @@ +struct Abc { + a []struct { + b string + } +} + +fn main() { + abc := Abc{ + a: [struct {'this is b'}] + } + + println(abc) +}