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:
parent
5cfe55b7e8
commit
8f08795689
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user