From bfa8e4bf86758dfdca945a8c1015787aca1b3b25 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 15 Dec 2020 11:31:34 +0800 Subject: [PATCH] parser: minor cleanup of `check()` (#7333) --- vlib/v/parser/parser.v | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index fe213bba41..d6f4bbde1a 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -396,15 +396,13 @@ fn (mut p Parser) check(expected token.Kind) { // for p.tok.kind in [.line_comment, .mline_comment] { // p.next() // } - if p.tok.kind != expected { - if p.tok.kind == .name { - p.error('unexpected name `$p.tok.lit`, expecting `$expected.str()`') - } else { - p.error('unexpected `$p.tok.kind.str()`, expecting `$expected.str()`') - } - return + if p.tok.kind == expected { + p.next() + } else if p.tok.kind == .name { + p.error('unexpected name `$p.tok.lit`, expecting `$expected.str()`') + } else { + p.error('unexpected `$p.tok.kind.str()`, expecting `$expected.str()`') } - p.next() } // JS functions can have multiple dots in their name: