parser: improve embedded struct parsing/better error for `Architecture []string` (#13995)
parent
3571f66a82
commit
93a5d03182
|
@ -0,0 +1,13 @@
|
||||||
|
vlib/v/checker/tests/struct_field_name_err.vv:2:2: error: field name `Architecture` cannot contain uppercase letters, use snake_case instead
|
||||||
|
1 | struct Release {
|
||||||
|
2 | Architecture []string
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
3 | Components []string
|
||||||
|
4 | }
|
||||||
|
vlib/v/checker/tests/struct_field_name_err.vv:3:2: error: field name `Components` cannot contain uppercase letters, use snake_case instead
|
||||||
|
1 | struct Release {
|
||||||
|
2 | Architecture []string
|
||||||
|
3 | Components []string
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
4 | }
|
||||||
|
5 |
|
|
@ -0,0 +1,9 @@
|
||||||
|
struct Release {
|
||||||
|
Architecture []string
|
||||||
|
Components []string
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
r := Release{}
|
||||||
|
println(r)
|
||||||
|
}
|
|
@ -184,7 +184,8 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
|
||||||
p.next()
|
p.next()
|
||||||
is_field_volatile = true
|
is_field_volatile = true
|
||||||
}
|
}
|
||||||
is_embed := ((p.tok.lit.len > 1 && p.tok.lit[0].is_capital())
|
is_embed := ((p.tok.lit.len > 1 && p.tok.lit[0].is_capital()
|
||||||
|
&& (p.peek_tok.kind != .lsbr || p.peek_token(2).kind != .rsbr))
|
||||||
|| p.peek_tok.kind == .dot) && language == .v && p.peek_tok.kind != .key_fn
|
|| 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_mut || is_field_global)
|
||||||
mut field_name := ''
|
mut field_name := ''
|
||||||
|
|
Loading…
Reference in New Issue