checker: more arr1=arr2 fixes

pull/7429/head
Alexander Medvednikov 2020-12-20 15:21:32 +01:00
parent 628021a7cf
commit 583c02316a
2 changed files with 4 additions and 3 deletions

View File

@ -173,7 +173,7 @@ pub fn (mut b Builder) resolve_deps() {
// graph of all imported modules // graph of all imported modules
pub fn (b &Builder) import_graph() &depgraph.DepGraph { pub fn (b &Builder) import_graph() &depgraph.DepGraph {
builtins := util.builtin_module_parts builtins := util.builtin_module_parts.clone()
mut graph := depgraph.new_dep_graph() mut graph := depgraph.new_dep_graph()
for p in b.parsed_files { for p in b.parsed_files {
mut deps := []string{} mut deps := []string{}

View File

@ -2210,9 +2210,10 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
continue continue
} }
if left_sym.kind == .array && if left_sym.kind == .array &&
assign_stmt.op == .assign && right_sym.kind == .array && left is ast.Ident && right is ast.Ident { assign_stmt.op in [.assign, .decl_assign] && right_sym.kind == .array && left is ast.Ident &&
right is ast.Ident {
// Do not allow `a = b`, only `a = b.clone()` // Do not allow `a = b`, only `a = b.clone()`
c.warn('use `array2 = array1.clone()` instead of `array1 = array2`', assign_stmt.pos) c.warn('use `array2 = array1.clone()` instead of `array2 = array1`', assign_stmt.pos)
} }
left_is_ptr := left_type.is_ptr() || left_sym.is_pointer() left_is_ptr := left_type.is_ptr() || left_sym.is_pointer()
if left_is_ptr { if left_is_ptr {