mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix parenexpr checking on assignment (#17593)
This commit is contained in:
parent
dc24df9510
commit
ddcc22fe08
@ -80,10 +80,18 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
||||
c.error('assignment mismatch: ${node.left.len} variable(s) but `${right_first.name}()` returns ${right_len} value(s)',
|
||||
node.pos)
|
||||
} else if right_first is ast.ParExpr {
|
||||
if right_first.expr is ast.CallExpr {
|
||||
if right_first.expr.return_type == ast.void_type {
|
||||
c.error('assignment mismatch: expected ${node.left.len} value(s) but `${right_first.expr.name}()` returns ${right_len} value(s)',
|
||||
node.pos)
|
||||
mut right_next := right_first
|
||||
for {
|
||||
if right_next.expr is ast.CallExpr {
|
||||
if (right_next.expr as ast.CallExpr).return_type == ast.void_type {
|
||||
c.error('assignment mismatch: expected ${node.left.len} value(s) but `${(right_next.expr as ast.CallExpr).name}()` returns ${right_len} value(s)',
|
||||
node.pos)
|
||||
}
|
||||
break
|
||||
} else if right_next.expr is ast.ParExpr {
|
||||
right_next = right_next.expr as ast.ParExpr
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1,3 +1,12 @@
|
||||
vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:6: warning: redundant parentheses are used
|
||||
1 | _ := ((((print(10)))))
|
||||
| ~~~~~~~~~~~~~~~~~
|
||||
vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:7: warning: redundant parentheses are used
|
||||
1 | _ := ((((print(10)))))
|
||||
| ~~~~~~~~~~~~~~~
|
||||
vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:8: warning: redundant parentheses are used
|
||||
1 | _ := ((((print(10)))))
|
||||
| ~~~~~~~~~~~~~
|
||||
vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:3: error: assignment mismatch: expected 1 value(s) but `print()` returns 0 value(s)
|
||||
1 | _ := (print(10))
|
||||
1 | _ := ((((print(10)))))
|
||||
| ~~
|
||||
|
@ -1 +1 @@
|
||||
_ := (print(10))
|
||||
_ := ((((print(10)))))
|
||||
|
Loading…
Reference in New Issue
Block a user