From b15780ae51e9aa313b333c406db62976b3e9183d Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 16 Apr 2020 12:00:05 +0800 Subject: [PATCH] parser: better const error --- vlib/v/parser/parser.v | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 6e0fdcd40c..d804bfb2f4 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1514,7 +1514,10 @@ fn (p mut Parser) const_decl() ast.ConstDecl { } pos := p.tok.position() p.check(.key_const) - p.check(.lpar) + if p.tok.kind != .lpar { + p.error('consts must be grouped, e.g.\nconst (\n\ta = 1\n)') + } + p.next() // ( var fields := []ast.ConstField for p.tok.kind != .rpar { if p.tok.kind == .comment {