diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index fd5d3b5c2d..4dc9f0f43d 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -563,11 +563,12 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_ g.auto_str_funcs.writeln('static string indent_${str_fn_name}($styp a, int indent_count) {') g.auto_str_funcs.writeln('\tstrings__Builder sb = strings__new_builder($info.size * 10);') g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("["));') + g.auto_str_funcs.writeln('\tfor (int i = 0; i < $info.size; ++i) {') if sym.kind == .function { g.auto_str_funcs.writeln('\t\tstring x = ${elem_str_fn_name}();') + g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, x);') } else { deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ) - g.auto_str_funcs.writeln('\tfor (int i = 0; i < $info.size; ++i) {') if should_use_indent_func(sym.kind) && !sym_has_str_method { if is_elem_ptr { g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT("$deref_label"));') diff --git a/vlib/v/tests/str_gen_test.v b/vlib/v/tests/str_gen_test.v index 1cfcd2d6c3..0ca979089d 100644 --- a/vlib/v/tests/str_gen_test.v +++ b/vlib/v/tests/str_gen_test.v @@ -438,3 +438,9 @@ fn test_multi_return() { value: 'two' })" } + +fn test_fixed_array_of_function() { + a := [println, println]! + println(a) + assert '$a' == '[fn (string), fn (string)]' +}