Skip to content

Commit 045adb6

Browse files
authored
parser: change warn to error, for const names with upper letter (fix #18838) (#18840)
1 parent 87dd5de commit 045adb6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

vlib/v/checker/tests/const_field_name_snake_case.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vlib/v/checker/tests/const_field_name_snake_case.vv:2:2: warning: const names cannot contain uppercase letters, use snake_case instead
1+
vlib/v/checker/tests/const_field_name_snake_case.vv:2:2: error: const names cannot contain uppercase letters, use snake_case instead
22
1 | const (
33
2 | Red = 1
44
| ~~~

vlib/v/parser/parser.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,8 +3689,8 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
36893689
pos := p.tok.pos()
36903690
name := p.check_name()
36913691
end_comments << p.eat_comments()
3692-
if util.contains_capital(name) {
3693-
p.warn_with_pos('const names cannot contain uppercase letters, use snake_case instead',
3692+
if !p.pref.translated && !p.is_translated && util.contains_capital(name) {
3693+
p.error_with_pos('const names cannot contain uppercase letters, use snake_case instead',
36943694
pos)
36953695
}
36963696
full_name := p.prepend_mod(name)

0 commit comments

Comments
 (0)