checker: warn/error about empty const blocks (#9252)

pull/9257/head
StunxFS 2021-03-11 16:43:04 -04:00 committed by GitHub
parent 5cfe55b7e8
commit 8f08795689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -2442,6 +2442,9 @@ pub fn (mut c Checker) return_stmt(mut return_stmt ast.Return) {
pub fn (mut c Checker) const_decl(mut node ast.ConstDecl) {
mut field_names := []string{}
mut field_order := []int{}
if node.fields.len == 0 {
c.warn('const block must have at least 1 declaration', node.pos)
}
for i, field in node.fields {
// TODO Check const name once the syntax is decided
if field.name in c.const_names {