1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
Delyan Angelov 2022-05-12 11:36:25 +03:00
parent 8830af5c89
commit b7ca4c1668
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
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() {
}