From 5e48817dc84b891fc949178ed38e149b06706304 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 27 Mar 2023 13:38:21 +0200 Subject: [PATCH] parser: remove duplicated pascal case check --- vlib/v/checker/checker.v | 5 ++++- vlib/v/checker/tests/incorrect_name_struct.out | 4 ++-- vlib/v/parser/struct.v | 5 ----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 68bb0016e..a4636be58 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -418,8 +418,11 @@ fn stripped_name(name string) string { } fn (mut c Checker) check_valid_pascal_case(name string, identifier string, pos token.Pos) { + if c.pref.translated || c.file.is_translated { + return + } sname := stripped_name(name) - if sname.len > 0 && !sname[0].is_capital() && !c.pref.translated && !c.file.is_translated { + if sname.len > 0 && !sname[0].is_capital() { c.error('${identifier} `${name}` must begin with capital letter', pos) } } diff --git a/vlib/v/checker/tests/incorrect_name_struct.out b/vlib/v/checker/tests/incorrect_name_struct.out index 03f1a9348..e06f4cea5 100644 --- a/vlib/v/checker/tests/incorrect_name_struct.out +++ b/vlib/v/checker/tests/incorrect_name_struct.out @@ -1,3 +1,3 @@ -vlib/v/checker/tests/incorrect_name_struct.vv:1:8: error: struct name `abc` must begin with capital letter +vlib/v/checker/tests/incorrect_name_struct.vv:1:1: error: struct name `abc` must begin with capital letter 1 | struct abc {} - | ~~~ \ No newline at end of file + | ~~~~~~~~~~ diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index b95d7aabf..aa08e83c9 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -69,11 +69,6 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { p.error('`${p.tok.lit}` lacks body') return ast.StructDecl{} } - if language == .v && !p.builtin_mod && !p.is_translated && name.len > 0 && !name[0].is_capital() - && !p.pref.translated && !p.is_translated && !is_anon { - p.error_with_pos('struct name `${name}` must begin with capital letter', name_pos) - return ast.StructDecl{} - } if name.len == 1 { p.error_with_pos('struct names must have more than one character', name_pos) return ast.StructDecl{} -- 2.39.5