From 2651b8957abccbc6bb21c64a4d6820750aed05a1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 30 Nov 2019 15:17:27 +0300 Subject: [PATCH] parser: fix unreachable code error in if a := opt() --- vlib/compiler/parser.v | 1 + vlib/net/urllib/urllib.v | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index b2f32b2bf7..ba3fa5d0fd 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -2663,6 +2663,7 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string { //token_idx: var_token_idx }) p.statements() + p.returns = false return 'void' } else { p.check_types(p.bool_expression(), 'bool') diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 652952c12e..dec444324e 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -626,17 +626,15 @@ fn parse_host(host string) ?string { return err } return host1 + host2 + host3 - } else { - i = host.last_index(':') - if i != -1 { - colon_port = host[i..] - if !valid_optional_port(colon_port) { - return error(error_msg('parse_host: invalid port $colon_port after host ', '')) - } + } + i = host.last_index(':') + if i != -1 { + colon_port = host[i..] + if !valid_optional_port(colon_port) { + return error(error_msg('parse_host: invalid port $colon_port after host ', '')) } } } - h := unescape(host, .encode_host) or { return err } @@ -852,8 +850,8 @@ fn parse_query_values(m mut Values, query string) ?bool { continue } mut value := '' - i = key.index('=') - if i >= 0 { + if idx := key.index('=') { + i = idx value = key[i+1..] key = key[..i] }