@@ -649,15 +649,15 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_
649649 is_elem_ptr := typ.is_ptr ()
650650 sym_has_str_method , str_method_expects_ptr , _ := sym.str_method_info ()
651651 elem_str_fn_name := g.get_str_fn (typ)
652+ def_arg := if info.is_fn_ret { '${g.typ(typ)} a[${info.size} ]' } else { '${styp} a' }
652653
653- g.definitions.writeln ('static string ${str_fn_name} (${styp} a ); // auto' )
654- g.auto_str_funcs.writeln ('static string ${str_fn_name} (${styp} a ) { return indent_${str_fn_name} (a, 0);}' )
655- g.definitions.writeln ('static string indent_${str_fn_name} (${styp} a , int indent_count); // auto' )
656- g.auto_str_funcs.writeln ('static string indent_${str_fn_name} (${styp} a , int indent_count) {' )
654+ g.definitions.writeln ('static string ${str_fn_name} (); // auto' )
655+ g.auto_str_funcs.writeln ('static string ${str_fn_name} (${def_arg} ) { return indent_${str_fn_name} (a, 0);}' )
656+ g.definitions.writeln ('static string indent_${str_fn_name} (${def_arg} , int indent_count); // auto' )
657+ g.auto_str_funcs.writeln ('static string indent_${str_fn_name} (${def_arg} , int indent_count) {' )
657658 g.auto_str_funcs.writeln ('\t strings__Builder sb = strings__new_builder(${info.size} * 10);' )
658659 g.auto_str_funcs.writeln ('\t strings__Builder_write_string(&sb, _SLIT("["));' )
659660 g.auto_str_funcs.writeln ('\t for (int i = 0; i < ${info.size} ; ++i) {' )
660- suffix := if info.is_fn_ret { '.ret_arr' } else { '' }
661661 if sym.kind == .function {
662662 g.auto_str_funcs.writeln ('\t\t string x = ${elem_str_fn_name} ();' )
663663 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, x);' )
@@ -666,30 +666,30 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_
666666 if should_use_indent_func (sym.kind) && ! sym_has_str_method {
667667 if is_elem_ptr {
668668 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, _SLIT("${deref_label} "));' )
669- g.auto_str_funcs.writeln ('\t\t if ( 0 == a${suffix} [i] ) {' )
669+ g.auto_str_funcs.writeln ('\t\t if ( 0 == a[i] ) {' )
670670 g.auto_str_funcs.writeln ('\t\t\t strings__Builder_write_string(&sb, _SLIT("0"));' )
671671 g.auto_str_funcs.writeln ('\t\t }else{' )
672- g.auto_str_funcs.writeln ('\t\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a${suffix} [i]) );' )
672+ g.auto_str_funcs.writeln ('\t\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a[i]) );' )
673673 g.auto_str_funcs.writeln ('\t\t }' )
674674 } else {
675- g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a${suffix} [i]) );' )
675+ g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a[i]) );' )
676676 }
677677 } else if sym.kind in [.f32 , .f64 ] {
678678 if sym.kind == .f32 {
679- field_str := str_intp_g32 ('a${suffix} [i]' )
679+ field_str := str_intp_g32 ('a[i]' )
680680 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${field_str} );' )
681681 } else {
682- field_str := str_intp_g64 ('a${suffix} [i]' )
682+ field_str := str_intp_g64 ('a[i]' )
683683 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${field_str} );' )
684684 }
685685 } else if sym.kind == .string {
686- field_str := str_intp_sq ('a${suffix} [i]' )
686+ field_str := str_intp_sq ('a[i]' )
687687 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${field_str} );' )
688688 } else if sym.kind == .rune {
689- tmp_str := str_intp_rune ('${elem_str_fn_name} ( ${deref} a${suffix} [i])' )
689+ tmp_str := str_intp_rune ('${elem_str_fn_name} ( ${deref} a[i])' )
690690 g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${tmp_str} );' )
691691 } else {
692- g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a${suffix} [i]));' )
692+ g.auto_str_funcs.writeln ('\t\t strings__Builder_write_string(&sb, ${elem_str_fn_name} ( ${deref} a[i]));' )
693693 }
694694 }
695695 g.auto_str_funcs.writeln ('\t\t if (i < ${info.size - 1} ) {' )
0 commit comments