cgen: fix generics fn str() (fix #7403) (#9940)

pull/9948/head
yuyi 2021-04-30 18:40:07 +08:00 committed by GitHub
parent fb685eee18
commit 844662e0d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -489,7 +489,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, styp string, str_fn_name stri
// TODO: this is a bit hacky. styp shouldn't be even parsed with _T_ // TODO: this is a bit hacky. styp shouldn't be even parsed with _T_
// use something different than g.typ for styp // use something different than g.typ for styp
clean_struct_v_type_name = clean_struct_v_type_name =
clean_struct_v_type_name.replace('_Array', '_array').replace('_T_', '<').replace('_', ', ') + clean_struct_v_type_name.replace('Array_', '[]').replace('_T_', '<').replace('_', ', ') +
'>' '>'
} }
clean_struct_v_type_name = util.strip_main_name(clean_struct_v_type_name) clean_struct_v_type_name = util.strip_main_name(clean_struct_v_type_name)

View File

@ -342,7 +342,7 @@ fn test_generic_struct_print_array_as_field() {
foo := Foo<[]string>{ foo := Foo<[]string>{
data: []string{} data: []string{}
} }
assert foo.str() == 'Foo<array, string>{\n data: []\n}' assert foo.str() == 'Foo<[]string>{\n data: []\n}'
} }
/* /*