1
0
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:
Alexander Medvednikov 2019-10-24 14:25:03 +03:00
parent 3d6bdc2dc3
commit 75a6c759c7
2 changed files with 5 additions and 1 deletions

View File

@ -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'

View File

@ -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