mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix panic on fn abc()?{ return error() }
This commit is contained in:
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 {
|
||||
|
5
vlib/v/checker/tests/error_fn_with_0_args.out
Normal file
5
vlib/v/checker/tests/error_fn_with_0_args.out
Normal file
@ -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 | }
|
3
vlib/v/checker/tests/error_fn_with_0_args.vv
Normal file
3
vlib/v/checker/tests/error_fn_with_0_args.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn abc() ? {
|
||||
return error()
|
||||
}
|
Loading…
Reference in New Issue
Block a user