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

parser: do not allow fn consts

This commit is contained in:
Alexander Medvednikov 2020-10-19 13:48:39 +02:00
parent 0d31b39f11
commit 37d6503437

View File

@ -1626,6 +1626,9 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
// name := p.check_name() // name := p.check_name()
// println('!!const: $name') // println('!!const: $name')
p.check(.assign) p.check(.assign)
if p.tok.kind == .key_fn {
p.error('const initializer fn literal is not a constant')
}
expr := p.expr(0) expr := p.expr(0)
field := ast.ConstField{ field := ast.ConstField{
name: full_name name: full_name