checker: remove "use `++` instead of `+= 1`"

pull/9358/head
Alexander Medvednikov 2021-03-18 01:37:36 +03:00
parent 6cfc2c217b
commit 88097125f7
3 changed files with 0 additions and 27 deletions

View File

@ -2871,15 +2871,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
&& left_sym.kind !in [.byteptr, .charptr, .struct_, .alias] { && left_sym.kind !in [.byteptr, .charptr, .struct_, .alias] {
c.error('invalid right operand: $left_sym.name $assign_stmt.op $right_sym.name', c.error('invalid right operand: $left_sym.name $assign_stmt.op $right_sym.name',
right.position()) 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 { .mult_assign, .div_assign {

View File

@ -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 | }

View File

@ -1,5 +0,0 @@
fn main() {
mut foo := 10
foo += 1
foo -= 1
}