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

parser: better const error

This commit is contained in:
yuyi 2020-04-16 12:00:05 +08:00 committed by GitHub
parent 5e4c5f189f
commit b15780ae51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1514,7 +1514,10 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
} }
pos := p.tok.position() pos := p.tok.position()
p.check(.key_const) 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 var fields := []ast.ConstField
for p.tok.kind != .rpar { for p.tok.kind != .rpar {
if p.tok.kind == .comment { if p.tok.kind == .comment {