parent
3907a1ab49
commit
9a744b6750
|
@ -131,7 +131,7 @@ fn test_map_init() {
|
||||||
one := 'one'
|
one := 'one'
|
||||||
three := 'three'
|
three := 'three'
|
||||||
m := map{
|
m := map{
|
||||||
one: 1
|
one: 1
|
||||||
'two': 2
|
'two': 2
|
||||||
three: 1 + 2
|
three: 1 + 2
|
||||||
}
|
}
|
||||||
|
@ -626,3 +626,9 @@ fn test_map_assign_empty_map_init() {
|
||||||
assert a == map[string]int{}
|
assert a == map[string]int{}
|
||||||
assert '$a' == '{}'
|
assert '$a' == '{}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_in_map_literal() {
|
||||||
|
assert 1 in map{
|
||||||
|
1: 'one'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -745,11 +745,12 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map {
|
.map {
|
||||||
elem_type := right.map_info().key_type
|
map_info := right.map_info()
|
||||||
c.check_expected(left_type, elem_type) or {
|
c.check_expected(left_type, map_info.key_type) or {
|
||||||
c.error('left operand to `$infix_expr.op` does not match the map key type: $err',
|
c.error('left operand to `$infix_expr.op` does not match the map key type: $err',
|
||||||
left_right_pos)
|
left_right_pos)
|
||||||
}
|
}
|
||||||
|
infix_expr.left_type = map_info.key_type
|
||||||
}
|
}
|
||||||
.string {
|
.string {
|
||||||
c.check_expected(left_type, right_type) or {
|
c.check_expected(left_type, right_type) or {
|
||||||
|
|
Loading…
Reference in New Issue