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

cgen: fix shared array.last() (#15379)

This commit is contained in:
yuyi 2022-08-08 18:11:38 +08:00 committed by GitHub
parent c7152a6ab6
commit 6a728e1674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1009,7 +1009,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
if !node.left.is_lvalue() {
g.write('ADDR($rec_cc_type, ')
has_cast = true
} else {
} else if node.name !in ['first', 'last', 'repeat'] {
g.write('&')
}
}

View File

@ -0,0 +1,13 @@
module main
fn test_shared_array_last() {
shared a := []int{}
lock {
a << 1
a << 2
}
rlock a {
println(a.last())
assert a.last() == 2
}
}