Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jun 1, 2024
1 parent 19c08f5 commit 6153df5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vlib/v/checker/tests/map_def_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vlib/v/checker/tests/map_def_err.vv:2:7: error: cannot use the map type without key and value definition
1 | struct Foo {
2 | bar map
| ~~~
3 | }
3 changes: 3 additions & 0 deletions vlib/v/checker/tests/map_def_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
struct Foo {
bar map
}
5 changes: 5 additions & 0 deletions vlib/v/parser/parse_type.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ fn (mut p Parser) parse_map_type() ast.Type {
}
p.next()
if p.tok.kind != .lsbr {
if p.inside_struct_field_decl {
p.error_with_pos('cannot use the map type without key and value definition',
p.prev_tok.pos())
return 0
}
return ast.map_type
}
p.check(.lsbr)
Expand Down

0 comments on commit 6153df5

Please sign in to comment.