checker: fix panic on `fn abc()?{ return error() }`
parent
d6e462a6ca
commit
b29bc9cdce
|
@ -2430,7 +2430,7 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
|
|||
return func.return_type
|
||||
}
|
||||
// `return error(err)` -> `return err`
|
||||
if fn_name == 'error' {
|
||||
if fn_name == 'error' && call_expr.args.len == 1 {
|
||||
arg := call_expr.args[0]
|
||||
call_expr.args[0].typ = c.expr(arg.expr)
|
||||
if call_expr.args[0].typ == ast.error_type {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
vlib/v/checker/tests/error_fn_with_0_args.vv:2:9: error: expected 1 arguments, but got 0
|
||||
1 | fn abc() ? {
|
||||
2 | return error()
|
||||
| ~~~~~~~
|
||||
3 | }
|
|
@ -0,0 +1,3 @@
|
|||
fn abc() ? {
|
||||
return error()
|
||||
}
|
Loading…
Reference in New Issue