From 013589e9fee0996fcc47e2372aea591e8e789fc7 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 28 Feb 2022 19:30:17 +0800 Subject: [PATCH] parser: minor cleanup in global_decl() (#13617) --- vlib/v/checker/tests/globals/unexpected_eof.out | 2 +- vlib/v/parser/parser.v | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/vlib/v/checker/tests/globals/unexpected_eof.out b/vlib/v/checker/tests/globals/unexpected_eof.out index f0a6cbcb23..789374a28a 100644 --- a/vlib/v/checker/tests/globals/unexpected_eof.out +++ b/vlib/v/checker/tests/globals/unexpected_eof.out @@ -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 diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 764ef19b7f..b8f9677076 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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