Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Feb 1, 2025
1 parent b8c7892 commit 84ccaa9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/parser/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
mut pre_comments := p.eat_comments()
no_body := p.tok.kind != .lcbr && p.tok.kind != .key_implements
if language == .v && no_body {
p.error('`${p.tok.lit}` lacks body')
p.error_with_pos('`${p.tok.lit}` lacks body', name_pos)
return ast.StructDecl{}
}
if name.len == 1 {
Expand Down
5 changes: 5 additions & 0 deletions vlib/v/parser/tests/struct_no_body_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vlib/v/parser/tests/struct_no_body_err.vv:1:8: error: `struct` lacks body
1 | struct Lexer
| ~~~~~
2 |
3 | struct Token {
10 changes: 10 additions & 0 deletions vlib/v/parser/tests/struct_no_body_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct Lexer

struct Token {
token_u string
}

fn main() {
token := Token{"this is a token"}
println(token.token_u)
}

0 comments on commit 84ccaa9

Please sign in to comment.