cgen: fix optional functions that return other optional functions

pull/4072/head
Alexander Medvednikov 2020-03-19 11:44:27 +01:00
parent b2f05e56b8
commit 74616d2900
1 changed files with 1 additions and 1 deletions

View File

@ -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]