File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,9 @@ fn (mut p Parser) parse_map_type() ast.Type {
163
163
p.check (.rsbr)
164
164
if p.tok.kind == .lsbr {
165
165
if p.peek_tok.kind ! in [.rsbr, .number] {
166
- p.error_with_pos ('maps can only have a single key' , p.peek_tok.pos ())
166
+ s := p.table.type_to_str (key_type)
167
+ p.error_with_pos ('maps can only have a single key. To declare a map use `map[${s} ]${p.peek_tok.lit} {}` instead' ,
168
+ p.peek_tok.pos ())
167
169
return 0
168
170
}
169
171
}
Original file line number Diff line number Diff line change 1
- vlib/v/parser/tests/map_key_twice_err.vv:1:14: error: maps can only have a single key
1
+ vlib/v/parser/tests/map_key_twice_err.vv:1:14: error: maps can only have a single key. To declare a map use `map[u8]u8{}` instead
2
2
1 | _ := map[u8][u8]{}
3
3
| ~~
4
4
2 |
You can’t perform that action at this time.
0 commit comments