From 9eac16b97605f8f419c183291ab722f26b90a1be Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 28 Sep 2019 22:20:34 +0300 Subject: [PATCH] parser: struct names must be capitalized --- compiler/main.v | 5 +++-- compiler/parser.v | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index b3144e8836..8cf7ca7457 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -473,7 +473,7 @@ string _STR_TMP(const char *fmt, ...) { fn (v mut V) gen_main_start(add_os_args bool){ v.cgen.genln('int main(int argc, char** argv) { ') - v.cgen.genln(' init_consts();') + v.cgen.genln(' init_consts();') if add_os_args && 'os' in v.table.imports { v.cgen.genln(' os__args = os__init_os_args(argc, (byteptr*)argv);') } @@ -678,7 +678,8 @@ fn (v mut V) add_v_files_to_compile() { continue } mod_path := v.find_module_path(mod) - // If we are in default mode, we don't parse vlib .v files, but header .vh files in + // If we are in default mode, we don't parse vlib .v files, but + // header .vh files in // TmpPath/vlib // These were generated by vfmt /* diff --git a/compiler/parser.v b/compiler/parser.v index 76f3eb7631..fc3fdaf89c 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -606,6 +606,9 @@ fn (p mut Parser) struct_decl() { if name.contains('_') && !p.pref.translated { p.error('type names cannot contain `_`') } + if !p.builtin_mod && !name[0].is_capital() { + p.error('struct names must be capitalized: `struct Foo {`, not `struct foo {`') + } if is_interface && !name.ends_with('er') { p.error('interface names temporarily have to end with `er` (e.g. `Speaker`, `Reader`)') }