mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check error for simple assignment with dumping of multireturn value (#15512)
This commit is contained in:
parent
939e9245db
commit
b83dd86d65
@ -17,7 +17,7 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
||||
mut right_len := node.right.len
|
||||
mut right_type0 := ast.void_type
|
||||
for i, mut right in node.right {
|
||||
if right in [ast.CallExpr, ast.IfExpr, ast.LockExpr, ast.MatchExpr] {
|
||||
if right in [ast.CallExpr, ast.IfExpr, ast.LockExpr, ast.MatchExpr, ast.DumpExpr] {
|
||||
if right in [ast.IfExpr, ast.MatchExpr] && node.left.len == node.right.len && !is_decl
|
||||
&& node.left[i] in [ast.Ident, ast.SelectorExpr] && !node.left[i].is_blank_ident() {
|
||||
c.expected_type = c.expr(node.left[i])
|
||||
|
@ -0,0 +1,6 @@
|
||||
vlib/v/checker/tests/assign_with_dump_multireturn_value.vv:5:3: error: assignment mismatch: 1 variable(s) 2 value(s)
|
||||
3 | }
|
||||
4 |
|
||||
5 | x := dump(two_returns())
|
||||
| ~~
|
||||
6 | println(x)
|
@ -0,0 +1,6 @@
|
||||
fn two_returns() (string, string) {
|
||||
return 'hello', 'world'
|
||||
}
|
||||
|
||||
x := dump(two_returns())
|
||||
println(x)
|
Loading…
Reference in New Issue
Block a user