1
0
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:
StunxFS 2022-08-26 00:08:05 -04:00 committed by GitHub
parent 939e9245db
commit b83dd86d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -17,7 +17,7 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
mut right_len := node.right.len mut right_len := node.right.len
mut right_type0 := ast.void_type mut right_type0 := ast.void_type
for i, mut right in node.right { 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 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() { && node.left[i] in [ast.Ident, ast.SelectorExpr] && !node.left[i].is_blank_ident() {
c.expected_type = c.expr(node.left[i]) c.expected_type = c.expr(node.left[i])

View File

@ -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)

View File

@ -0,0 +1,6 @@
fn two_returns() (string, string) {
return 'hello', 'world'
}
x := dump(two_returns())
println(x)