@@ -365,10 +365,11 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
365
365
}
366
366
} else if mut right is ast.Ident && right.obj is ast.Var
367
367
&& right.or_expr.kind == .absent {
368
- if (right.obj as ast.Var ).ct_type_var != .no_comptime {
368
+ right_obj_var := right.obj as ast.Var
369
+ if right_obj_var.ct_type_var != .no_comptime {
369
370
ctyp := c.comptime.get_comptime_var_type (right)
370
371
if ctyp != ast.void_type {
371
- left.obj.ct_type_var = (right.obj as ast.Var ) .ct_type_var
372
+ left.obj.ct_type_var = right_obj_var .ct_type_var
372
373
left.obj.typ = ctyp
373
374
}
374
375
}
@@ -522,10 +523,9 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
522
523
}
523
524
} else if mut left is ast.Ident && left.kind != .blank_ident
524
525
&& right is ast.IndexExpr {
525
- if (right as ast.IndexExpr ).left is ast.Ident
526
- && (right as ast.IndexExpr ).index is ast.RangeExpr
527
- && ((right as ast.IndexExpr ).left.is_mut () || left.is_mut ())
528
- && ! c.inside_unsafe {
526
+ right_index_expr := right as ast.IndexExpr
527
+ if right_index_expr.left is ast.Ident && right_index_expr.index is ast.RangeExpr
528
+ && (right_index_expr.left.is_mut () || left.is_mut ()) && ! c.inside_unsafe {
529
529
// `mut a := arr[..]` auto add clone() -> `mut a := arr[..].clone()`
530
530
c.add_error_detail_with_pos ('To silence this notice, use either an explicit `a[..].clone()`,
531
531
or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.' ,
0 commit comments