mirror of
https://github.com/vlang/v.git
synced 2025-09-09 15:27:05 -04:00
parent
3acbd580d4
commit
0fd669d203
@ -372,6 +372,9 @@ fn (mut g Gen) index_of_fixed_array(node ast.IndexExpr, sym ast.TypeSymbol) {
|
||||
} else {
|
||||
g.expr(node.left)
|
||||
}
|
||||
if node.left_type.has_flag(.shared_f) {
|
||||
g.write('.val')
|
||||
}
|
||||
}
|
||||
g.write('[')
|
||||
if g.is_direct_array_access || g.pref.translated || node.index is ast.IntegerLiteral {
|
||||
|
18
vlib/v/tests/concurrency/shared_array_indexing_test.v
Normal file
18
vlib/v/tests/concurrency/shared_array_indexing_test.v
Normal file
@ -0,0 +1,18 @@
|
||||
struct Foo {
|
||||
mut:
|
||||
bar shared [10]bool
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
mut a := Foo{
|
||||
bar: [10]bool{}
|
||||
}
|
||||
lock a.bar {
|
||||
a.bar[0] = true
|
||||
a.bar[1] = false
|
||||
}
|
||||
rlock a.bar {
|
||||
assert a.bar[0] == true
|
||||
assert a.bar[1] == false
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user