cgen: fix `x in shared_map` (#13442)
parent
37c151efe5
commit
0eee012ae9
|
@ -430,9 +430,12 @@ fn (mut g Gen) infix_expr_in_op(node ast.InfixExpr) {
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
}
|
}
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
if !right.typ.is_ptr() {
|
if !right.typ.is_ptr() || right.typ.has_flag(.shared_f) {
|
||||||
g.write('ADDR(map, ')
|
g.write('ADDR(map, ')
|
||||||
g.expr(node.right)
|
g.expr(node.right)
|
||||||
|
if right.typ.has_flag(.shared_f) {
|
||||||
|
g.write('->val')
|
||||||
|
}
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else {
|
} else {
|
||||||
g.expr(node.right)
|
g.expr(node.right)
|
||||||
|
|
|
@ -155,3 +155,17 @@ fn test_shared_map_iteration() {
|
||||||
assert n1 == 1
|
assert n1 == 1
|
||||||
assert n2 == 1
|
assert n2 == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_shared_map_in() {
|
||||||
|
shared m := {
|
||||||
|
'qwe': 12.75
|
||||||
|
'rtz': -0.125
|
||||||
|
'k': 17
|
||||||
|
}
|
||||||
|
rlock m {
|
||||||
|
assert 'qwe' in m
|
||||||
|
assert 'rtz' in m
|
||||||
|
assert 'k' in m
|
||||||
|
assert 'zxc' !in m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue