mirror of
https://github.com/vlang/v.git
synced 2025-09-12 17:07:11 -04:00
parser: check struct embed with wrong position (#19245)
This commit is contained in:
parent
6fb4a481f8
commit
e414b54f68
@ -8,8 +8,8 @@ struct User {
|
||||
}
|
||||
|
||||
struct FamousUser {
|
||||
pub:
|
||||
User
|
||||
pub:
|
||||
aka string
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|
||||
&& (p.peek_tok.line_nr != p.tok.line_nr || p.peek_tok.kind !in [.name, .amp])
|
||||
&& (p.peek_tok.kind != .lsbr || p.peek_token(2).kind != .rsbr))
|
||||
|| p.peek_tok.kind == .dot) && language == .v && p.peek_tok.kind != .key_fn
|
||||
is_on_top := ast_fields.len == 0 && !(is_field_mut || is_field_global)
|
||||
is_on_top := ast_fields.len == 0 && !(is_field_pub || is_field_mut || is_field_global)
|
||||
mut field_name := ''
|
||||
mut typ := ast.Type(0)
|
||||
mut type_pos := token.Pos{}
|
||||
|
@ -0,0 +1,7 @@
|
||||
vlib/v/parser/tests/struct_embed_wrong_pos_in_pub_err.vv:6:5: error: struct embedding must be declared at the beginning of the struct body
|
||||
4 | pub struct ThreadSafeLog {
|
||||
5 | pub:
|
||||
6 | Log
|
||||
| ~~~
|
||||
7 | pub mut:
|
||||
8 | mu Xyz
|
11
vlib/v/parser/tests/struct_embed_wrong_pos_in_pub_err.vv
Normal file
11
vlib/v/parser/tests/struct_embed_wrong_pos_in_pub_err.vv
Normal file
@ -0,0 +1,11 @@
|
||||
struct Log {}
|
||||
struct Xyz {}
|
||||
|
||||
pub struct ThreadSafeLog {
|
||||
pub:
|
||||
Log
|
||||
pub mut:
|
||||
mu Xyz
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user