From 045adb6600226dac4339af97aaccc2d5a2d189e1 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 11 Jul 2023 22:48:53 +0800 Subject: [PATCH] parser: change warn to error, for const names with upper letter (fix #18838) (#18840) --- vlib/v/checker/tests/const_field_name_snake_case.out | 2 +- vlib/v/parser/parser.v | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/v/checker/tests/const_field_name_snake_case.out b/vlib/v/checker/tests/const_field_name_snake_case.out index ff997e441d..352ff4bf68 100644 --- a/vlib/v/checker/tests/const_field_name_snake_case.out +++ b/vlib/v/checker/tests/const_field_name_snake_case.out @@ -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 ( 2 | Red = 1 | ~~~ diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 4bba5147c1..ec37d71e22 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3689,8 +3689,8 @@ fn (mut p Parser) const_decl() ast.ConstDecl { pos := p.tok.pos() name := p.check_name() end_comments << p.eat_comments() - if util.contains_capital(name) { - p.warn_with_pos('const names cannot contain uppercase letters, use snake_case instead', + if !p.pref.translated && !p.is_translated && util.contains_capital(name) { + p.error_with_pos('const names cannot contain uppercase letters, use snake_case instead', pos) } full_name := p.prepend_mod(name)