mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix generation of array names in generic structs (#7324)
This commit is contained in:
parent
4f986ccac4
commit
a3c3fd4d20
@ -530,7 +530,7 @@ fn (g &Gen) cc_type2(t table.Type) string {
|
||||
mut sgtyps := '_T'
|
||||
for gt in sym.info.generic_types {
|
||||
gts := g.table.get_type_symbol(if gt.has_flag(.generic) { g.unwrap_generic(gt) } else { gt })
|
||||
sgtyps += '_$gts.name'
|
||||
sgtyps += '_$gts.cname'
|
||||
}
|
||||
styp += sgtyps
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
|
||||
}
|
||||
gts := p.table.get_type_symbol(gt)
|
||||
bs_name += gts.name
|
||||
bs_cname += gts.name
|
||||
bs_cname += gts.cname
|
||||
generic_types << gt
|
||||
if p.tok.kind != .comma {
|
||||
break
|
||||
|
@ -288,6 +288,14 @@ fn test_struct_from_other_module() {
|
||||
assert g.msg.name == ''
|
||||
}
|
||||
|
||||
fn test_generic_struct_print_array_as_field() {
|
||||
foo := Foo<[]string>{
|
||||
data: []string{}
|
||||
}
|
||||
assert foo.str() == 'Foo<array, string>{\n data: []\n}'
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
struct Abc{ x int y int z int }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user