parser: do not allow 1 char struct names
parent
5423a15f46
commit
670820cc59
|
@ -1,4 +1,4 @@
|
|||
vlib/v/checker/tests/struct_pub_field.v:9:4: error: field `i` of struct `A` is immutable
|
||||
vlib/v/checker/tests/struct_pub_field.v:9:4: error: field `i` of struct `Foo` is immutable
|
||||
7 | i: 1
|
||||
8 | }
|
||||
9 | a.i = 2
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
struct A {
|
||||
struct Foo {
|
||||
i int
|
||||
}
|
||||
|
||||
fn main() {
|
||||
a := A{
|
||||
a := Foo{
|
||||
i: 1
|
||||
}
|
||||
a.i = 2
|
||||
|
|
|
@ -41,6 +41,9 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
|
|||
if language == .v && p.mod != 'builtin' && name.len > 0 && !name[0].is_capital() {
|
||||
p.error_with_pos('struct name `$name` must begin with capital letter', end_pos)
|
||||
}
|
||||
if name.len == 1 {
|
||||
p.error_with_pos('struct names must have more than one character', end_pos)
|
||||
}
|
||||
// println('struct decl $name')
|
||||
mut ast_fields := []ast.StructField{}
|
||||
mut fields := []table.Field{}
|
||||
|
|
Loading…
Reference in New Issue