mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix generic array of alias (#17571)
This commit is contained in:
parent
638805be63
commit
737e7f6410
@ -992,7 +992,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
||||
&& !typ_sym.has_method(node.name) {
|
||||
unwrapped_rec_type = (typ_sym.info as ast.Alias).parent_type
|
||||
typ_sym = g.table.sym(unwrapped_rec_type)
|
||||
} else if typ_sym.kind == .array && !typ_sym.has_method(node.name) {
|
||||
} else if typ_sym.kind == .array && !typ_sym.has_method(node.name) && node.name != 'str' {
|
||||
typ := g.table.unaliased_type((typ_sym.info as ast.Array).elem_type)
|
||||
typ_idx := g.table.find_type_idx(g.table.array_name(typ))
|
||||
if typ_idx > 0 {
|
||||
|
13
vlib/v/tests/generic_array_of_alias_test.v
Normal file
13
vlib/v/tests/generic_array_of_alias_test.v
Normal file
@ -0,0 +1,13 @@
|
||||
import datatypes
|
||||
|
||||
type Distance = int
|
||||
|
||||
struct Foo {
|
||||
field datatypes.LinkedList[Distance]
|
||||
}
|
||||
|
||||
fn test_generic_array_of_alias() {
|
||||
foo := Foo{}
|
||||
println(foo)
|
||||
assert '${foo.field}' == '[]'
|
||||
}
|
Loading…
Reference in New Issue
Block a user