checker: fix a compiler panic on `fntest()?(&int,&int){return test()?}`

Delyan Angelov 2022-05-12 11:36:25 +03:00 committed by Jef Roosens
parent 49d57dfccd
commit f77085e34f
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 13 additions and 1 deletions

View File

@ -135,7 +135,7 @@ pub fn (mut c Checker) return_stmt(mut node ast.Return) {
pos)
}
if exp_type.is_ptr() && got_typ.is_ptr() {
mut r_expr := &node.exprs[i]
mut r_expr := &node.exprs[expr_idxs[i]]
if mut r_expr is ast.Ident {
if mut r_expr.obj is ast.Var {
mut obj := unsafe { &r_expr.obj }

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/return_optional_of_multiple_results.vv:2:9: error: `?` is not needed, use `return test()`
1 | fn test() ?(&int, &int) {
2 | return test() ?
| ~~~~~~
3 | }
4 |

View File

@ -0,0 +1,6 @@
fn test() ?(&int, &int) {
return test() ?
}
fn main() {
}