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:
@@ -1009,7 +1009,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||||||
if !node.left.is_lvalue() {
|
if !node.left.is_lvalue() {
|
||||||
g.write('ADDR($rec_cc_type, ')
|
g.write('ADDR($rec_cc_type, ')
|
||||||
has_cast = true
|
has_cast = true
|
||||||
} else {
|
} else if node.name !in ['first', 'last', 'repeat'] {
|
||||||
g.write('&')
|
g.write('&')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
vlib/v/tests/shared_array_last_test.v
Normal file
13
vlib/v/tests/shared_array_last_test.v
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user