parser: minor cleanup in global_decl() (#13617)

pull/13618/head
yuyi 2022-02-28 19:30:17 +08:00 committed by GitHub
parent a0d9e6e1c2
commit 013589e9fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 14 deletions

View File

@ -1,3 +1,3 @@
vlib/v/checker/tests/globals/unexpected_eof.vv:3:1: error: unexpected eof, expecting ´)´
vlib/v/checker/tests/globals/unexpected_eof.vv:3:1: error: unexpected eof, expecting `)`
1 | __global (
2 | x string

View File

@ -3360,7 +3360,7 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
for {
comments = p.eat_comments()
if is_block && p.tok.kind == .eof {
p.error('unexpected eof, expecting ´)´')
p.error('unexpected eof, expecting `)`')
return ast.GlobalDecl{}
}
if p.tok.kind == .rpar {
@ -3375,18 +3375,9 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
if has_expr {
p.next() // =
expr = p.expr(0)
match expr {
ast.CastExpr {
typ = (expr as ast.CastExpr).typ
}
ast.StructInit {
typ = (expr as ast.StructInit).typ
}
ast.ArrayInit {
typ = (expr as ast.ArrayInit).typ
}
ast.ChanInit {
typ = (expr as ast.ChanInit).typ
match mut expr {
ast.CastExpr, ast.StructInit, ast.ArrayInit, ast.ChanInit {
typ = expr.typ
}
ast.BoolLiteral, ast.IsRefType {
typ = ast.bool_type