From 865c30118f76eaf93dfd79b3016ea5286e21e52c Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Sun, 6 Dec 2020 01:37:00 +1100 Subject: [PATCH] checker: add fix & better comment for previous commit --- vlib/v/checker/checker.v | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index c421c08bfd..71805e9555 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -39,7 +39,7 @@ pub mut: warnings []errors.Warning error_lines []int // to avoid printing multiple errors for the same line expected_type table.Type - expected_or_type table.Type // expected_type is reset by the time we get to or block stmts/exprs + expected_or_type table.Type // fn() or { 'this type' } eg. string. expected or block type cur_fn &ast.FnDecl // current function const_decl string const_deps []string @@ -1060,7 +1060,7 @@ pub fn (mut c Checker) call_expr(mut call_expr ast.CallExpr) table.Type { call_expr.free_receiver = true } } - c.expected_or_type = call_expr.return_type + c.expected_or_type = call_expr.return_type.clear_flag(.optional) c.stmts(call_expr.or_block.stmts) c.expected_or_type = table.void_type return typ @@ -2532,7 +2532,6 @@ fn (mut c Checker) stmt(node ast.Stmt) { node.typ = c.expr(node.expr) c.expected_type = table.void_type c.check_expr_opt_call(node.expr, table.void_type) - // c.expected_type = table.void_type // TODO This should work, even if it's prolly useless .-. // node.typ = c.check_expr_opt_call(node.expr, table.void_type) }