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

cgen: fix alias of map clone() (fix #18384) (#18386)

This commit is contained in:
yuyi 2023-06-09 17:58:38 +08:00 committed by GitHub
parent 01b20485c3
commit 5300441c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1277,7 +1277,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
g.get_free_method(rec_type)
}
mut has_cast := false
if left_sym.kind == .map && node.name in ['clone', 'move'] {
if final_left_sym.kind == .map && node.name in ['clone', 'move'] {
receiver_type_name = 'map'
}
if final_left_sym.kind == .array && !(left_sym.kind == .alias && left_sym.has_method(node.name))

View File

@ -0,0 +1,13 @@
type Fields = map[string]string
fn test_alias_map_clone() {
f := Fields({
's': 'a'
})
s := f.clone()
println(s)
assert s == {
's': 'a'
}
}