Skip to content

Commit

Permalink
checker: fix lambda expr with result (#20433)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jan 8, 2024
1 parent 5cd4933 commit c7b8da7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/lambda_expr.v
Expand Up @@ -63,7 +63,7 @@ pub fn (mut c Checker) lambda_expr(mut node ast.LambdaExpr, exp_typ ast.Type) as

mut stmts := []ast.Stmt{}
mut has_return := false
if return_type == ast.void_type {
if return_type.clear_flags(.option, .result) == ast.void_type {
stmts << ast.ExprStmt{
pos: node.pos
expr: node.expr
Expand Down
8 changes: 8 additions & 0 deletions vlib/v/tests/lambda_expr_with_result_test.v
@@ -0,0 +1,8 @@
fn test_lambda_expr_with_result() {
take_lambda(|| println('abc'))
assert true
}

fn take_lambda(l fn () !) {
l() or { panic(err) }
}

0 comments on commit c7b8da7

Please sign in to comment.