parser: struct names must be capitalized

pull/2159/head
Alexander Medvednikov 2019-09-28 22:20:34 +03:00
parent a4cbe78d97
commit 9eac16b976
2 changed files with 6 additions and 2 deletions

View File

@ -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
/*

View File

@ -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`)')
}