parser: better const error

pull/4433/head
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
1 changed files with 4 additions and 1 deletions

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 {