@@ -420,17 +420,22 @@ fn (mut g Gen) gen_str_for_interface(info ast.Interface, styp string, typ_str st
420
420
fn_builder.write_string2 ('\t if (x._typ == _${styp} _${sub_sym.cname} _index)' ,
421
421
' return ${res} ;' )
422
422
} else {
423
- mut val := '${func_name} (${deref} (${sub_sym.cname} *)x._${sub_sym.cname} '
424
- if should_use_indent_func (sub_sym.kind) && ! sym_has_str_method {
425
- val + = ', indent_count'
423
+ if ! (sub_sym.kind == .array && g.table.sym (g.table.value_type (typ)).cname == styp) {
424
+ mut val := '${func_name} (${deref} (${sub_sym.cname} *)x._${sub_sym.cname} '
425
+ if should_use_indent_func (sub_sym.kind) && ! sym_has_str_method {
426
+ val + = ', indent_count'
427
+ }
428
+ val + = ')'
429
+ res := 'str_intp(2, _MOV((StrIntpData[]){
430
+ {_SLIT("${clean_interface_v_type_name} ("), ${si_s_code} , {.d_s = ${val} }},
431
+ {_SLIT(")"), 0, {.d_c = 0 }}
432
+ }))'
433
+ fn_builder.write_string2 ('\t if (x._typ == _${styp} _${sub_sym.cname} _index)' ,
434
+ ' return ${res} ;\n ' )
435
+ } else {
436
+ fn_builder.write_string2 ('\t if (x._typ == _${styp} _${sub_sym.cname} _index)' ,
437
+ ' return _SLIT("<circular>");\n ' )
426
438
}
427
- val + = ')'
428
- res := 'str_intp(2, _MOV((StrIntpData[]){
429
- {_SLIT("${clean_interface_v_type_name} ("), ${si_s_code} , {.d_s = ${val} }},
430
- {_SLIT(")"), 0, {.d_c = 0 }}
431
- }))'
432
- fn_builder.write_string2 ('\t if (x._typ == _${styp} _${sub_sym.cname} _index)' ,
433
- ' return ${res} ;\n ' )
434
439
}
435
440
}
436
441
fn_builder.writeln ('\t return _SLIT("unknown interface value");' )
0 commit comments