mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
parent
af0a73f04f
commit
ac00d441ad
@ -614,7 +614,15 @@ fn (mut g Gen) infix_expr_in_op(node ast.InfixExpr) {
|
||||
} else if right.unaliased_sym.kind == .map {
|
||||
g.write('_IN_MAP(')
|
||||
if !left.typ.is_ptr() {
|
||||
styp := g.styp(node.left_type)
|
||||
mut sym_map := g.table.sym(node.right_type)
|
||||
if sym_map.info is ast.Alias {
|
||||
sym_map = g.table.sym((sym_map.info as ast.Alias).parent_type)
|
||||
}
|
||||
styp := g.styp(if sym_map.info is ast.Map {
|
||||
(sym_map.info as ast.Map).key_type
|
||||
} else {
|
||||
node.left_type
|
||||
})
|
||||
g.write('ADDR(${styp}, ')
|
||||
g.expr(node.left)
|
||||
g.write(')')
|
||||
|
18
vlib/v/tests/builtin_maps/map_generic_keys_with_in_op_test.v
Normal file
18
vlib/v/tests/builtin_maps/map_generic_keys_with_in_op_test.v
Normal file
@ -0,0 +1,18 @@
|
||||
import datatypes
|
||||
|
||||
fn x() {
|
||||
mut set1 := datatypes.Set[string]{}
|
||||
set1.add('')
|
||||
assert set1.exists('')
|
||||
}
|
||||
|
||||
fn y() {
|
||||
mut set2 := datatypes.Set[int]{}
|
||||
set2.add(1)
|
||||
assert set2.exists(1)
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
x()
|
||||
y()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user