1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: change warn to error, for const names with upper letter (fix #18838) (#18840)

This commit is contained in:
yuyi 2023-07-11 22:48:53 +08:00 committed by GitHub
parent 87dd5de191
commit 045adb6600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/const_field_name_snake_case.vv:2:2: warning: const names cannot contain uppercase letters, use snake_case instead vlib/v/checker/tests/const_field_name_snake_case.vv:2:2: error: const names cannot contain uppercase letters, use snake_case instead
1 | const ( 1 | const (
2 | Red = 1 2 | Red = 1
| ~~~ | ~~~

View File

@ -3689,8 +3689,8 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
pos := p.tok.pos() pos := p.tok.pos()
name := p.check_name() name := p.check_name()
end_comments << p.eat_comments() end_comments << p.eat_comments()
if util.contains_capital(name) { if !p.pref.translated && !p.is_translated && util.contains_capital(name) {
p.warn_with_pos('const names cannot contain uppercase letters, use snake_case instead', p.error_with_pos('const names cannot contain uppercase letters, use snake_case instead',
pos) pos)
} }
full_name := p.prepend_mod(name) full_name := p.prepend_mod(name)