From 2795f929fabaef70b0c8e737b7ee79186ffff4ba Mon Sep 17 00:00:00 2001 From: Swastik Baranwal Date: Mon, 28 Dec 2020 23:05:34 +0530 Subject: [PATCH] checker: update check for arr=arr1 (#7651) --- vlib/builtin/array_test.v | 1 + vlib/v/checker/checker.v | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 3836c36fc1..ee3b892b74 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -352,6 +352,7 @@ fn test_mut_arg() { fn test_clone() { nums := [1, 2, 3, 4, 100] + _ = nums nums2 := nums.clone() assert nums2.len == 5 assert nums.str() == '[1, 2, 3, 4, 100]' diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 95051a003c..fe266e347d 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2293,7 +2293,8 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { continue } if left_sym.kind == .array && !c.inside_unsafe && assign_stmt.op in [.assign, .decl_assign] && - right_sym.kind == .array && left is ast.Ident && right is ast.Ident { + right_sym.kind == .array && + (left is ast.Ident && !left.is_blank_ident()) && right is ast.Ident { // Do not allow `a = b`, only `a = b.clone()` c.error('use `array2 = array1.clone()` instead of `array2 = array1` (or use `unsafe`)', assign_stmt.pos)