1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

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");')