diff --git a/cmd/tools/vvet/tests/const_dynamic_array_notice.out b/cmd/tools/vvet/tests/const_dynamic_array_notice.out index 4a8de48357..d19b161a6c 100644 --- a/cmd/tools/vvet/tests/const_dynamic_array_notice.out +++ b/cmd/tools/vvet/tests/const_dynamic_array_notice.out @@ -1 +1 @@ -cmd/tools/vvet/tests/const_dynamic_array_notice.vv:1: notice: use a fixed array, instead of a dynamic one +cmd/tools/vvet/tests/const_dynamic_array_notice.vv:1: notice: Use a fixed array instead of a dynamic one diff --git a/cmd/tools/vvet/tests/prog_without_main_fn.out b/cmd/tools/vvet/tests/prog_without_main_fn.out index 8099390f22..88c18347cd 100644 --- a/cmd/tools/vvet/tests/prog_without_main_fn.out +++ b/cmd/tools/vvet/tests/prog_without_main_fn.out @@ -1 +1 @@ -cmd/tools/vvet/tests/prog_without_main_fn.vv:1: notice: use a fixed array, instead of a dynamic one +cmd/tools/vvet/tests/prog_without_main_fn.vv:1: notice: Use a fixed array instead of a dynamic one diff --git a/cmd/tools/vvet/vvet.v b/cmd/tools/vvet/vvet.v index ebd10d8628..63b12624af 100644 --- a/cmd/tools/vvet/vvet.v +++ b/cmd/tools/vvet/vvet.v @@ -262,7 +262,7 @@ fn (mut vt Vet) stmts(stmts []ast.Stmt) { fn (mut vt Vet) stmt(stmt ast.Stmt) { match stmt { - ast.ConstDecl { vt.exprs(stmt.fields.map(it.expr)) } + ast.ConstDecl { vt.const_decl(stmt) } ast.ExprStmt { vt.expr(stmt.expr) } ast.Return { vt.exprs(stmt.exprs) } ast.AssertStmt { vt.expr(stmt.expr) } @@ -310,6 +310,16 @@ fn (mut vt Vet) expr(expr ast.Expr) { } } +fn (mut vt Vet) const_decl(stmt ast.ConstDecl) { + for field in stmt.fields { + if field.expr is ast.ArrayInit && !field.expr.is_fixed { + vt.notice('Use a fixed array instead of a dynamic one', field.expr.pos.line_nr, + .unknown) + } + vt.expr(field.expr) + } +} + fn (vt &Vet) vprintln(s string) { if !vt.opt.is_verbose { return diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 2f438a9741..0b18106d58 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3891,10 +3891,6 @@ fn (mut p Parser) const_decl() ast.ConstDecl { return ast.ConstDecl{} } expr := p.expr(0) - if expr is ast.ArrayInit && !expr.is_fixed && p.pref.is_vet { - p.vet_notice('use a fixed array, instead of a dynamic one', pos.line_nr, vet.FixKind.unknown, - .default) - } if is_block { end_comments << p.eat_comments(same_line: true) }