From 74616d2900761b3919684287b6b688fd6f9cfde9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 19 Mar 2020 11:44:27 +0100 Subject: [PATCH] cgen: fix optional functions that return other optional functions --- vlib/v/gen/cgen.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index caf5cb833f..b07b366012 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -1322,7 +1322,7 @@ fn (g mut Gen) return_statement(it ast.Return) { else if it.exprs.len == 1 { g.write(' ') // `return opt_ok(expr)` for functions that expect an optional - if table.type_is_optional(g.fn_decl.return_type) { + if table.type_is_optional(g.fn_decl.return_type) && !table.type_is_optional(it.types[0]) { mut is_none := false mut is_error := false expr0 := it.exprs[0]