From 8f08795689f6dc95f73ebb5aec4933e96d003670 Mon Sep 17 00:00:00 2001 From: StunxFS <56417208+StunxFS@users.noreply.github.com> Date: Thu, 11 Mar 2021 16:43:04 -0400 Subject: [PATCH] checker: warn/error about empty const blocks (#9252) --- vlib/v/checker/checker.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 9425ab0bb4..e98941e368 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 {