diff --git a/vlib/compiler/if_match.v b/vlib/compiler/if_match.v index a45e736e81..61f2eb7ff8 100644 --- a/vlib/compiler/if_match.v +++ b/vlib/compiler/if_match.v @@ -203,7 +203,7 @@ fn (p mut Parser) match_statement(is_expr bool) string { i++ p.fgen_nl() } - p.error('match expression requires `else`') + p.error('match must be exhaustive') //p.returns = false // only get here when no default, so return is not guaranteed return '' } diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 3b970c511f..f102fb85b8 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -1386,8 +1386,8 @@ fn ($v.name mut $v.typ) $p.cur_fn.name (...) { } else { next := p.peek_token() - if next.tok == .number && next.lit== '1' { - p.warn('use ++ instead of += 1') + if next.tok == .number && next.lit== '1' { + p.error('use `++` instead of `+= 1`') } p.gen(' += ') } diff --git a/vlib/compiler/tests/defer_test.v b/vlib/compiler/tests/defer_test.v index c2e71900d3..b64292a86b 100644 --- a/vlib/compiler/tests/defer_test.v +++ b/vlib/compiler/tests/defer_test.v @@ -16,7 +16,7 @@ fn test_defer() { } fn set_num(i int, n mut Num) { - defer { n.val+=1 } + defer { n.val++ } println("Hi") if i < 5 { return diff --git a/vlib/compiler/tests/mut_test.v b/vlib/compiler/tests/mut_test.v index 9be62a3e1d..8b039ffc7c 100644 --- a/vlib/compiler/tests/mut_test.v +++ b/vlib/compiler/tests/mut_test.v @@ -41,7 +41,8 @@ fn test_mut_2() { b.a[zero].v << 5 b.a[0].v[zero] = 3 - b.a[0].v[b.a[zero].v[zero]] += 1b.a[0].v[b.a[0].v[zero]] += 1 + b.a[0].v[b.a[zero].v[zero]]++ + b.a[0].v[b.a[0].v[zero]]++ assert b.a[0].v.len == 5 assert b.a[0].v[0] == 3 diff --git a/vlib/compiler/tests/pointers_test.v b/vlib/compiler/tests/pointers_test.v index 8c3993b7fa..b3fb8e40ad 100644 --- a/vlib/compiler/tests/pointers_test.v +++ b/vlib/compiler/tests/pointers_test.v @@ -3,7 +3,7 @@ fn test_pointer_arithmetic() { arr := [1,2,3,4] unsafe { mut parr := *int(arr.data) - parr += 1 + parr++ assert 2 == *parr parr++ assert 3 == *parr diff --git a/vlib/sdl/examples/tvintris/tvintris.v b/vlib/sdl/examples/tvintris/tvintris.v index 279d7547c1..403235bb27 100644 --- a/vlib/sdl/examples/tvintris/tvintris.v +++ b/vlib/sdl/examples/tvintris/tvintris.v @@ -299,7 +299,7 @@ fn main() { // println('JOY2 id=${game2.joy_id}') // delay uses milliseconds so 1000 ms / 30 frames (30fps) roughly = 33.3333 ms/frame - time_per_frame := 1000.0 / 30.0 + time_per_frame := 1000.0 / 30.0 game.k_fire = P1FIRE game.k_up = P1UP @@ -339,7 +339,7 @@ fn main() { mut total_frames := u32(0) for { - total_frames += 1 + total_frames++ start_ticks := sdl.get_perf_counter() g1 := game @@ -405,13 +405,13 @@ fn main() { break } end_ticks := sdl.get_perf_counter() - + total_frame_ticks += end_ticks-start_ticks elapsed_time := f64(end_ticks - start_ticks) / f64(sdl.get_perf_frequency()) // current_fps := 1.0 / elapsed_time - + // should limit system to (1 / time_per_frame) fps - sdl.delay(u32(math.floor(time_per_frame - elapsed_time))) + sdl.delay(u32(math.floor(time_per_frame - elapsed_time))) } if game.font != voidptr(0) { C.TTF_CloseFont(game.font) diff --git a/vlib/strings/builder_js.v b/vlib/strings/builder_js.v index 936b01d5e4..1c2ac55d95 100644 --- a/vlib/strings/builder_js.v +++ b/vlib/strings/builder_js.v @@ -19,7 +19,7 @@ pub fn new_builder(initial_size int) Builder { pub fn (b mut Builder) write_b(data byte) { b.buf << data - b.len += 1 + b.len++ } pub fn (b mut Builder) write(s string) { diff --git a/vlib/strings/builder_test.v b/vlib/strings/builder_test.v index cb81f51c1c..0e48a01574 100644 --- a/vlib/strings/builder_test.v +++ b/vlib/strings/builder_test.v @@ -25,7 +25,7 @@ fn test_big_sb() { for i in 0..n { sb.writeln(i.str()) sb2.write('+') - } + } s := sb.str() lines := s.split_into_lines() assert lines.len == n @@ -35,8 +35,8 @@ fn test_big_sb() { assert lines[98765] == '98765' println(sb2.len) assert sb2.len == n - -} + +} fn test_byte_write() { mut sb := strings.new_builder(100) @@ -44,7 +44,7 @@ fn test_byte_write() { mut count := 0 for word in temp_str { sb.write_b(word) - count += 1 + count++ assert count == sb.len } assert sb.str() == temp_str