From 88097125f7aa03c1fff166409a890f522f5f97a8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 18 Mar 2021 01:37:36 +0300 Subject: [PATCH] checker: remove "use `++` instead of `+= 1`" --- vlib/v/checker/checker.v | 9 --------- .../checker/tests/plus_or_minus_assign_one_err.out | 13 ------------- .../v/checker/tests/plus_or_minus_assign_one_err.vv | 5 ----- 3 files changed, 27 deletions(-) delete mode 100644 vlib/v/checker/tests/plus_or_minus_assign_one_err.out delete mode 100644 vlib/v/checker/tests/plus_or_minus_assign_one_err.vv diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 2b8e80e134..66653991d9 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2871,15 +2871,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { && left_sym.kind !in [.byteptr, .charptr, .struct_, .alias] { c.error('invalid right operand: $left_sym.name $assign_stmt.op $right_sym.name', right.position()) - } else if right is ast.IntegerLiteral { - if right.val == '1' { - op := if assign_stmt.op == .plus_assign { - token.Kind.inc - } else { - token.Kind.dec - } - c.error('use `$op` instead of `$assign_stmt.op 1`', assign_stmt.pos) - } } } .mult_assign, .div_assign { diff --git a/vlib/v/checker/tests/plus_or_minus_assign_one_err.out b/vlib/v/checker/tests/plus_or_minus_assign_one_err.out deleted file mode 100644 index 69d38a3391..0000000000 --- a/vlib/v/checker/tests/plus_or_minus_assign_one_err.out +++ /dev/null @@ -1,13 +0,0 @@ -vlib/v/checker/tests/plus_or_minus_assign_one_err.vv:3:6: error: use `++` instead of `+= 1` - 1 | fn main() { - 2 | mut foo := 10 - 3 | foo += 1 - | ~~ - 4 | foo -= 1 - 5 | } -vlib/v/checker/tests/plus_or_minus_assign_one_err.vv:4:6: error: use `--` instead of `-= 1` - 2 | mut foo := 10 - 3 | foo += 1 - 4 | foo -= 1 - | ~~ - 5 | } diff --git a/vlib/v/checker/tests/plus_or_minus_assign_one_err.vv b/vlib/v/checker/tests/plus_or_minus_assign_one_err.vv deleted file mode 100644 index a0dead3ecf..0000000000 --- a/vlib/v/checker/tests/plus_or_minus_assign_one_err.vv +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - mut foo := 10 - foo += 1 - foo -= 1 -} \ No newline at end of file