mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
enum snake_case check
This commit is contained in:
parent
3d6bdc2dc3
commit
75a6c759c7
@ -25,6 +25,9 @@ fn (p mut Parser) enum_decl(_enum_name string) {
|
||||
mut fields := []string
|
||||
for p.tok == .name {
|
||||
field := p.check_name()
|
||||
if contains_capital(field) {
|
||||
p.warn('enum values cannot contain uppercase letters, use snake_case instead')
|
||||
}
|
||||
fields << field
|
||||
p.fgenln('')
|
||||
name := '${mod_gen_name(p.mod)}__${enum_name}_$field'
|
||||
|
@ -1544,7 +1544,8 @@ fn (p mut Parser) var_decl() {
|
||||
p.error_with_token_index('redefinition of `$var_name`', var_token_idx)
|
||||
}
|
||||
// mut specified with assignment
|
||||
if /*is_assign && implicit*/ known_var && var_is_mut {
|
||||
//if /*is_assign && implicit*/ known_var && var_is_mut {
|
||||
if known_var && var_is_mut {
|
||||
p.error_with_token_index('cannot specify mutability for existing var `$var_name`, only for new vars', var_token_idx)
|
||||
}
|
||||
// assignment, but var does not exist
|
||||
|
Loading…
Reference in New Issue
Block a user