cgen: format the generated source code by gen_str_for_union_sum_type() (#14026)

pull/13758/merge
yuyi 2022-04-14 20:26:10 +08:00 committed by GitHub
parent 72c2dc805d
commit c4dff0d797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -472,7 +472,7 @@ fn (mut g Gen) gen_str_for_union_sum_type(info ast.SumType, styp string, str_fn_
{_SLIT("${clean_sum_type_v_type_name}(\'"), $c.si_s_code, {.d_s = $val}},
{_SLIT("\')"), 0, {.d_c = 0 }}
}))'
fn_builder.write_string('\t\tcase $typ.idx(): return $res;')
fn_builder.write_string('\t\tcase $typ.idx(): return $res;\n')
} else {
mut val := '${func_name}(${deref}($typ_str*)x._$sym.cname'
if should_use_indent_func(sym.kind) && !sym_has_str_method {
@ -483,7 +483,7 @@ fn (mut g Gen) gen_str_for_union_sum_type(info ast.SumType, styp string, str_fn_
{_SLIT("${clean_sum_type_v_type_name}("), $c.si_s_code, {.d_s = $val}},
{_SLIT(")"), 0, {.d_c = 0 }}
}))'
fn_builder.write_string('\t\tcase $typ.idx(): return $res;')
fn_builder.write_string('\t\tcase $typ.idx(): return $res;\n')
}
}
fn_builder.writeln('\t\tdefault: return _SLIT("unknown sum type value");')