mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: update check for arr=arr1 (#7651)
This commit is contained in:
parent
9631eac9c5
commit
2795f929fa
@ -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]'
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user