mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: remove "use ++
instead of += 1
"
This commit is contained in:
parent
6cfc2c217b
commit
88097125f7
@ -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 {
|
||||
|
@ -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 | }
|
@ -1,5 +0,0 @@
|
||||
fn main() {
|
||||
mut foo := 10
|
||||
foo += 1
|
||||
foo -= 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user