From 7333b1706c40e3e70d4af8e24aca4b9d838d6715 Mon Sep 17 00:00:00 2001 From: zakuro Date: Sun, 7 Mar 2021 03:42:34 +0900 Subject: [PATCH] checker: minor cleanup: clear_flag(.optional) in check_expr_opt_call (#9139) --- vlib/v/checker/checker.v | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 483439da05..dd3136b9c9 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2082,10 +2082,7 @@ pub fn (mut c Checker) check_expr_opt_call(expr ast.Expr, ret_type table.Type) t } else { c.check_or_expr(expr.or_block, ret_type, expr.return_type.clear_flag(.optional)) } - // remove optional flag - // return ret_type.clear_flag(.optional) - // TODO: currently unwrapped in assign, would need to refactor assign to unwrap here - return ret_type + return ret_type.clear_flag(.optional) } else if expr.or_block.kind == .block { c.error('unexpected `or` block, the function `$expr.name` does not return an optional', expr.or_block.pos) @@ -2630,10 +2627,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { } } } - // we are unwrapping here instead if check_expr_opt_call currently - if left_type.has_flag(.optional) { - left_type = left_type.clear_flag(.optional) - } } else { // Make sure the variable is mutable c.fail_if_immutable(left)