1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix optional functions that return other optional functions

This commit is contained in:
Alexander Medvednikov 2020-03-19 11:44:27 +01:00
parent b2f05e56b8
commit 74616d2900

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]