checker: update error message for `if 'a' in 'abcd' {`

pull/13038/head
Delyan Angelov 2022-01-05 12:21:07 +02:00
parent ba9aad1d92
commit 57fa9768d5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 6 additions and 6 deletions

View File

@ -623,7 +623,7 @@ pub fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
node.left_type = map_info.key_type node.left_type = map_info.key_type
} }
else { else {
c.error('`$node.op.str()` can only be used with an array/map/string', c.error('`$node.op.str()` can only be used with arrays and maps',
node.pos) node.pos)
} }
} }

View File

@ -12,21 +12,21 @@ vlib/v/checker/tests/in_mismatch_type.vv:13:5: error: left operand to `in` does
| ~~~~~~ | ~~~~~~
14 | println('yeah') 14 | println('yeah')
15 | } 15 | }
vlib/v/checker/tests/in_mismatch_type.vv:16:7: error: `in` can only be used with an array/map/string vlib/v/checker/tests/in_mismatch_type.vv:16:7: error: `in` can only be used with arrays and maps
14 | println('yeah') 14 | println('yeah')
15 | } 15 | }
16 | if 3 in s { 16 | if 3 in s {
| ~~ | ~~
17 | println('dope') 17 | println('dope')
18 | } 18 | }
vlib/v/checker/tests/in_mismatch_type.vv:19:9: error: `in` can only be used with an array/map/string vlib/v/checker/tests/in_mismatch_type.vv:19:9: error: `in` can only be used with arrays and maps
17 | println('dope') 17 | println('dope')
18 | } 18 | }
19 | if `a` in s { 19 | if `a` in s {
| ~~ | ~~
20 | println("oh no :'(") 20 | println("oh no :'(")
21 | } 21 | }
vlib/v/checker/tests/in_mismatch_type.vv:22:7: error: `in` can only be used with an array/map/string vlib/v/checker/tests/in_mismatch_type.vv:22:7: error: `in` can only be used with arrays and maps
20 | println("oh no :'(") 20 | println("oh no :'(")
21 | } 21 | }
22 | if 1 in 12 { 22 | if 1 in 12 {
@ -70,8 +70,8 @@ vlib/v/checker/tests/in_mismatch_type.vv:37:5: error: left operand to `!in` does
39 | } 39 | }
vlib/v/checker/tests/in_mismatch_type.vv:41:5: error: left operand to `!in` does not match the map key type: expected `string`, not `int literal` vlib/v/checker/tests/in_mismatch_type.vv:41:5: error: left operand to `!in` does not match the map key type: expected `string`, not `int literal`
39 | } 39 | }
40 | 40 |
41 | if 5 !in m { 41 | if 5 !in m {
| ~~~~~~~ | ~~~~~~~
42 | println('yay') 42 | println('yay')
43 | } 43 | }