1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

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) { pub fn (mut c Checker) const_decl(mut node ast.ConstDecl) {
mut field_names := []string{} mut field_names := []string{}
mut field_order := []int{} 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 { for i, field in node.fields {
// TODO Check const name once the syntax is decided // TODO Check const name once the syntax is decided
if field.name in c.const_names { if field.name in c.const_names {