checker: cleanup `map = {}` processing (#13563)

pull/13573/head
yuyi 2022-02-22 22:04:54 +08:00 committed by GitHub
parent 6a876d4170
commit 6486fffc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 16 deletions

View File

@ -92,22 +92,6 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
} }
left_type = c.expr(left) left_type = c.expr(left)
c.expected_type = c.unwrap_generic(left_type) c.expected_type = c.unwrap_generic(left_type)
// `map = {}`
if left_type != 0 {
sym := c.table.sym(left_type)
if sym.kind == .map {
if node.right.len <= i {
// `map_1, map_2, map_3 = f()`, where f returns (map[int]int, map[int]int, map[int]int)
// i.e. 3 left parts of the assignment, but just 1 right part
} else {
if node.right[i] is ast.StructInit {
c.warn('assigning a struct literal to a map is deprecated - use `map{}` instead',
node.right[i].pos())
node.right[i] = ast.MapInit{}
}
}
}
}
} }
if node.right_types.len < node.left.len { // first type or multi return types added above if node.right_types.len < node.left.len { // first type or multi return types added above
old_inside_ref_lit := c.inside_ref_lit old_inside_ref_lit := c.inside_ref_lit