mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
v.parser: fix the error message position, for a struct Abc
, that lacks a body (#23627)
This commit is contained in:
parent
e68fab82c4
commit
8f99e65425
@ -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 {
|
||||
|
5
vlib/v/parser/tests/struct_no_body_err.out
Normal file
5
vlib/v/parser/tests/struct_no_body_err.out
Normal file
@ -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
vlib/v/parser/tests/struct_no_body_err.vv
Normal file
10
vlib/v/parser/tests/struct_no_body_err.vv
Normal file
@ -0,0 +1,10 @@
|
||||
struct Lexer
|
||||
|
||||
struct Token {
|
||||
token_u string
|
||||
}
|
||||
|
||||
fn main() {
|
||||
token := Token{"this is a token"}
|
||||
println(token.token_u)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user