mirror of
https://github.com/vlang/v.git
synced 2025-09-15 10:27:19 -04:00
checker: fix lambda expr with result (#20433)
This commit is contained in:
parent
5cd4933280
commit
c7b8da7ffe
@ -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 stmts := []ast.Stmt{}
|
||||||
mut has_return := false
|
mut has_return := false
|
||||||
if return_type == ast.void_type {
|
if return_type.clear_flags(.option, .result) == ast.void_type {
|
||||||
stmts << ast.ExprStmt{
|
stmts << ast.ExprStmt{
|
||||||
pos: node.pos
|
pos: node.pos
|
||||||
expr: node.expr
|
expr: node.expr
|
||||||
|
8
vlib/v/tests/lambda_expr_with_result_test.v
Normal file
8
vlib/v/tests/lambda_expr_with_result_test.v
Normal file
@ -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) }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user