1
0
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:
yuyi 2023-03-09 20:57:14 +08:00 committed by GitHub
parent 638805be63
commit 737e7f6410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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 {

View 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}' == '[]'
}