From a2efb5319db355ac40479c82c5ec4b713b5cb05d Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 14 Jan 2021 10:51:13 +0800 Subject: [PATCH] all: change `[1,2,3]!!` to `[1,2,3]!` (#8101) --- examples/sokol/sounds/wav_player.v | 12 ++--- vlib/builtin/array_eq_test.v | 50 +++++++++---------- vlib/encoding/base64/base64.v | 4 +- vlib/term/ui/color.v | 2 +- vlib/v/ast/ast.v | 2 +- vlib/v/gen/js/tests/array.v | 6 +-- vlib/v/parser/containers.v | 2 +- vlib/v/tests/conversions_test.v | 4 +- vlib/v/tests/fixed_array_init_test.v | 28 +++++------ vlib/v/tests/str_gen_test.v | 24 ++++----- .../tests/string_interpolation_struct_test.v | 2 +- vlib/v/tests/type_voidptr_test.v | 6 +-- vlib/v/tests/typeof_test.v | 8 +-- 13 files changed, 75 insertions(+), 75 deletions(-) diff --git a/examples/sokol/sounds/wav_player.v b/examples/sokol/sounds/wav_player.v index 47306dd1e9..6c7d6cf900 100644 --- a/examples/sokol/sounds/wav_player.v +++ b/examples/sokol/sounds/wav_player.v @@ -124,10 +124,10 @@ fn read_wav_file_samples(fpath string) ?[]f32 { mut offset := u32(0) rh := &RIFFHeader(pbytes) // eprintln('rh: $rh') - if rh.riff != [byte(`R`), `I`, `F`, `F`]!! { + if rh.riff != [byte(`R`), `I`, `F`, `F`]! { return error('WAV should start with `RIFF`') } - if rh.form_type != [byte(`W`), `A`, `V`, `E`]!! { + if rh.form_type != [byte(`W`), `A`, `V`, `E`]! { return error('WAV should have `WAVE` form type') } if rh.file_size + 8 != bytes.len { @@ -145,15 +145,15 @@ fn read_wav_file_samples(fpath string) ?[]f32 { // eprintln('ch: $ch') // eprintln('p: $pbytes | offset: $offset | bytes.len: $bytes.len') // //////// - if ch.chunk_type == [byte(`L`), `I`, `S`, `T`]!! { + if ch.chunk_type == [byte(`L`), `I`, `S`, `T`]! { continue } // - if ch.chunk_type == [byte(`i`), `d`, `3`, ` `]!! { + if ch.chunk_type == [byte(`i`), `d`, `3`, ` `]! { continue } // - if ch.chunk_type == [byte(`f`), `m`, `t`, ` `]!! { + if ch.chunk_type == [byte(`f`), `m`, `t`, ` `]! { // eprintln('`fmt ` chunk') rf = &RIFFFormat(&ch.chunk_data) // eprintln('fmt riff format: $rf') @@ -169,7 +169,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 { continue } // - if ch.chunk_type == [byte(`d`), `a`, `t`, `a`]!! { + if ch.chunk_type == [byte(`d`), `a`, `t`, `a`]! { if rf == 0 { return error('`data` chunk should be after `fmt ` chunk') } diff --git a/vlib/builtin/array_eq_test.v b/vlib/builtin/array_eq_test.v index 280f58069d..6a68541642 100644 --- a/vlib/builtin/array_eq_test.v +++ b/vlib/builtin/array_eq_test.v @@ -12,37 +12,37 @@ fn test_eq() { } fn test_fixed_array_eq() { - a1 := [1, 2, 3]!! - assert a1 == [1, 2, 3]!! - assert a1 != [2, 3, 4]!! + a1 := [1, 2, 3]! + assert a1 == [1, 2, 3]! + assert a1 != [2, 3, 4]! - a2 := [[1, 2]!!, [3, 4]!!]!! - assert a2 == [[1, 2]!!, [3, 4]!!]!! - assert a2 != [[3, 4]!!, [1, 2]!!]!! + a2 := [[1, 2]!, [3, 4]!]! + assert a2 == [[1, 2]!, [3, 4]!]! + assert a2 != [[3, 4]!, [1, 2]!]! - a3 := [[1, 2], [3, 4]]!! - assert a3 == [[1, 2], [3, 4]]!! - assert a3 != [[1, 1], [2, 2]]!! + a3 := [[1, 2], [3, 4]]! + assert a3 == [[1, 2], [3, 4]]! + assert a3 != [[1, 1], [2, 2]]! - a4 := [[`a`, `b`], [`c`, `d`]]!! - assert a4 == [[`a`, `b`], [`c`, `d`]]!! - assert a4 != [[`c`, `a`], [`a`, `b`]]!! + a4 := [[`a`, `b`], [`c`, `d`]]! + assert a4 == [[`a`, `b`], [`c`, `d`]]! + assert a4 != [[`c`, `a`], [`a`, `b`]]! - a5 := [['aaa', 'bbb'], ['ccc', 'ddd']]!! - assert a5 == [['aaa', 'bbb'], ['ccc', 'ddd']]!! - assert a5 != [['abc', 'def'], ['ccc', 'ddd']]!! + a5 := [['aaa', 'bbb'], ['ccc', 'ddd']]! + assert a5 == [['aaa', 'bbb'], ['ccc', 'ddd']]! + assert a5 != [['abc', 'def'], ['ccc', 'ddd']]! - a6 := [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]!! - assert a6 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]!! - assert a6 != [['aaa', 'bbb']!!, ['aaa', 'ddd']!!]!! + a6 := [['aaa', 'bbb']!, ['ccc', 'ddd']!]! + assert a6 == [['aaa', 'bbb']!, ['ccc', 'ddd']!]! + assert a6 != [['aaa', 'bbb']!, ['aaa', 'ddd']!]! - a7 := [[1, 2]!!, [3, 4]!!] - assert a7 == [[1, 2]!!, [3, 4]!!] - assert a7 != [[2, 3]!!, [1, 2]!!] + a7 := [[1, 2]!, [3, 4]!] + assert a7 == [[1, 2]!, [3, 4]!] + assert a7 != [[2, 3]!, [1, 2]!] - a8 := [['aaa', 'bbb']!!, ['ccc', 'ddd']!!] - assert a8 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!] - assert a8 != [['bbb', 'aaa']!!, ['cccc', 'dddd']!!] + a8 := [['aaa', 'bbb']!, ['ccc', 'ddd']!] + assert a8 == [['aaa', 'bbb']!, ['ccc', 'ddd']!] + assert a8 != [['bbb', 'aaa']!, ['cccc', 'dddd']!] } fn test_fixed_array_literal_eq() { @@ -54,7 +54,7 @@ fn test_fixed_array_literal_eq() { assert [[1, 1]!, [2, 2]!]! == [[1, 1]!, [2, 2]!]! assert [[1, 1]!, [2, 2]!]! != [[1, 2]!, [2, 3]!]! - + assert [[1, 1]!, [2, 2]!] == [[1, 1]!, [2, 2]!] assert [[1, 1]!, [2, 2]!] != [[1, 2]!, [2, 3]!] } diff --git a/vlib/encoding/base64/base64.v b/vlib/encoding/base64/base64.v index a93fdf47cc..1e4ca663ab 100644 --- a/vlib/encoding/base64/base64.v +++ b/vlib/encoding/base64/base64.v @@ -11,9 +11,9 @@ const ( 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51]!! + 47, 48, 49, 50, 51]! - ending_table = [0, 2, 1]!! + ending_table = [0, 2, 1]! enc_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ) diff --git a/vlib/term/ui/color.v b/vlib/term/ui/color.v index 39616da062..e0ce7f2821 100644 --- a/vlib/term/ui/color.v +++ b/vlib/term/ui/color.v @@ -5,7 +5,7 @@ module ui const ( - value_range = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]!! + value_range = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]! color_table = init_color_table() ) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 53e34bd0c2..e4621d8b9d 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -891,7 +891,7 @@ pub: exprs []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array ecmnts [][]Comment // optional iembed comments after each expr is_fixed bool - has_val bool // fixed size literal `[expr, expr]!!` + has_val bool // fixed size literal `[expr, expr]!` mod string len_expr Expr // len: expr cap_expr Expr // cap: expr diff --git a/vlib/v/gen/js/tests/array.v b/vlib/v/gen/js/tests/array.v index 66fa87dbe7..ee302a4ee0 100644 --- a/vlib/v/gen/js/tests/array.v +++ b/vlib/v/gen/js/tests/array.v @@ -111,11 +111,11 @@ println(cc) println(dd) // fixed arrays: implemented as normal arrays -f1 := [1, 2, 3, 4, 5]!! +f1 := [1, 2, 3, 4, 5]! mut f2 := [8]f32 f2[0] = f32(1.23) -f3 := ['foo', 'bar']!! -f4 := [u64(0xffffffffffffffff), 0xdeadface]!! +f3 := ['foo', 'bar']! +f4 := [u64(0xffffffffffffffff), 0xdeadface]! println(' $f1 diff --git a/vlib/v/parser/containers.v b/vlib/v/parser/containers.v index e8c486e791..e47e04f170 100644 --- a/vlib/v/parser/containers.v +++ b/vlib/v/parser/containers.v @@ -88,7 +88,7 @@ fn (mut p Parser) array_init() ast.ArrayInit { } if p.tok.kind == .not && p.tok.line_nr == p.prev_tok.line_nr { last_pos = p.tok.position() - p.warn_with_pos('use e.g. `[1, 2, 3]!` instead of `[1, 2, 3]!!`', last_pos) + p.error_with_pos('use e.g. `[1, 2, 3]!` instead of `[1, 2, 3]!!`', last_pos) p.next() } } diff --git a/vlib/v/tests/conversions_test.v b/vlib/v/tests/conversions_test.v index 10b6d1961d..a8cbb5684a 100644 --- a/vlib/v/tests/conversions_test.v +++ b/vlib/v/tests/conversions_test.v @@ -6,9 +6,9 @@ fn test_conv_to_bool() { assert b // check true -> 1 assert int(b) == 1 - + // branchless tests (can be important for manual optimization) - arr := [7,8]!! + arr := [7,8]! e := arr[int(b)] assert e == 8 b = e < 0 diff --git a/vlib/v/tests/fixed_array_init_test.v b/vlib/v/tests/fixed_array_init_test.v index 0ea1c12d56..2cb27106a2 100644 --- a/vlib/v/tests/fixed_array_init_test.v +++ b/vlib/v/tests/fixed_array_init_test.v @@ -1,26 +1,26 @@ fn test_fixed_array_lit_init() { - a1 := ['1', '2', '3']!! + a1 := ['1', '2', '3']! assert typeof(a1).name == '[3]string' assert '$a1' == "['1', '2', '3']" - a2 := ['a', 'b']!! + a2 := ['a', 'b']! assert typeof(a2).name == '[2]string' assert '$a2' == "['a', 'b']" - c1 := [1, 2, 3]!! + c1 := [1, 2, 3]! assert typeof(c1).name == '[3]int' assert '$c1' == '[1, 2, 3]' - c2 := [i16(1), 2, 3]!! + c2 := [i16(1), 2, 3]! assert typeof(c2).name == '[3]i16' assert '$c2' == '[1, 2, 3]' - mut c3 := [i64(1), 2, 3]!! + mut c3 := [i64(1), 2, 3]! assert typeof(c3).name == '[3]i64' assert '$c3' == '[1, 2, 3]' - mut c4 := [u64(1), 2, 3]!! + mut c4 := [u64(1), 2, 3]! assert typeof(c4).name == '[3]u64' assert '$c4' == '[1, 2, 3]' - mut d1 := [1.1, 2.2, 3.3]!! + mut d1 := [1.1, 2.2, 3.3]! assert typeof(d1).name == '[3]f64' assert '$d1' == '[1.1, 2.2, 3.3]' - mut d2 := [f32(1.1), 2.2, 3.3]!! + mut d2 := [f32(1.1), 2.2, 3.3]! assert typeof(d2).name == '[3]f32' assert '$d2' == '[1.1, 2.2, 3.3]' } @@ -28,21 +28,21 @@ fn test_fixed_array_lit_init() { fn test_fixed_type_init() { a := [2]int{} assert a == [2]int{} - assert a == [0, 0]!! + assert a == [0, 0]! assert a == a - mut c := [3, 3]!! + mut c := [3, 3]! assert a != c - assert c == [3, 3]!! + assert c == [3, 3]! c = [2]int{} assert a == c } fn test_fixed_custom_init() { a := [2]byte{init: 7} - assert a == [byte(7), 7]!! + assert a == [byte(7), 7]! mut b := [3]int{} - assert b == [0, 0, 0]!! + assert b == [0, 0, 0]! // assign b = [3]int{init: 5} - assert b == [5, 5, 5]!! + assert b == [5, 5, 5]! } diff --git a/vlib/v/tests/str_gen_test.v b/vlib/v/tests/str_gen_test.v index 892d2aa6fb..59044365b7 100644 --- a/vlib/v/tests/str_gen_test.v +++ b/vlib/v/tests/str_gen_test.v @@ -86,56 +86,56 @@ fn test_map_of_bools() { fn test_fixed_array_of_floats() { // f64 array - aa := [1.2, 3.4, 5.67]!! + aa := [1.2, 3.4, 5.67]! assert aa.str() == '[1.2, 3.4, 5.67]' assert '$aa' == '[1.2, 3.4, 5.67]' // f32 array - bb := [f32(1.2), 3.4, 5.67]!! + bb := [f32(1.2), 3.4, 5.67]! assert bb.str() == '[1.2, 3.4, 5.67]' assert '$bb' == '[1.2, 3.4, 5.67]' } fn test_fixed_array_of_bools() { - aa := [true, false, true]!! + aa := [true, false, true]! assert aa.str() == '[true, false, true]' assert '$aa' == '[true, false, true]' } fn test_fixed_array_of_ints() { // int - a1 := [11, 22, 33]!! + a1 := [11, 22, 33]! assert a1.str() == '[11, 22, 33]' assert '$a1' == '[11, 22, 33]' // u32 - a2 := [u32(11), 22, 33]!! + a2 := [u32(11), 22, 33]! assert a2.str() == '[11, 22, 33]' assert '$a2' == '[11, 22, 33]' // i16 - b1 := [i16(11), 22, 33]!! + b1 := [i16(11), 22, 33]! assert b1.str() == '[11, 22, 33]' assert '$b1' == '[11, 22, 33]' // u16 - b2 := [u16(11), 22, 33]!! + b2 := [u16(11), 22, 33]! assert b2.str() == '[11, 22, 33]' assert '$b2' == '[11, 22, 33]' // i64 - c1 := [i64(11), 22, 33]!! + c1 := [i64(11), 22, 33]! assert c1.str() == '[11, 22, 33]' assert '$c1' == '[11, 22, 33]' // u64 - c2 := [u64(11), 22, 33]!! + c2 := [u64(11), 22, 33]! assert c2.str() == '[11, 22, 33]' assert '$c2' == '[11, 22, 33]' } fn test_fixed_array_of_runes() { - aa := [`a`, `b`, `c`]!! + aa := [`a`, `b`, `c`]! assert aa.str() == '[`a`, `b`, `c`]' assert '$aa' == '[`a`, `b`, `c`]' } fn test_fixed_array_of_strings() { - aa := ['aa', 'bb', 'cc']!! + aa := ['aa', 'bb', 'cc']! assert aa.str() == "['aa', 'bb', 'cc']" assert '$aa' == "['aa', 'bb', 'cc']" } @@ -243,7 +243,7 @@ fn test_alias_in_array() { type Alias2 = int fn test_alias_in_fixed_array() { - t := [Alias1(1)]!! + t := [Alias1(1)]! assert t.str() == '[1]' assert '$t' == '[1]' } diff --git a/vlib/v/tests/string_interpolation_struct_test.v b/vlib/v/tests/string_interpolation_struct_test.v index f721d64e3a..1329ace688 100644 --- a/vlib/v/tests/string_interpolation_struct_test.v +++ b/vlib/v/tests/string_interpolation_struct_test.v @@ -27,7 +27,7 @@ pub mut: fn test_fixed_array_struct_string_interpolation() { mut ctx := Context{} x := 2.32 - ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!! + ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]! s := '$ctx' assert s.starts_with('Context{') assert s.contains('vb: [1.1, 2.32, 3.3, 4.4, 5, 6, 7, 8.9]') diff --git a/vlib/v/tests/type_voidptr_test.v b/vlib/v/tests/type_voidptr_test.v index a2856128d3..03de9bb56d 100644 --- a/vlib/v/tests/type_voidptr_test.v +++ b/vlib/v/tests/type_voidptr_test.v @@ -14,8 +14,8 @@ fn memcpy(mut dest voidptr, src voidptr, len u32) voidptr { } fn test_mut_voidptr_arg() { - mut a := [1, 2]!! - b := [3, 4]!! + mut a := [1, 2]! + b := [3, 4]! memcpy(mut a, b, sizeof(int)) - assert a == [3, 2]!! + assert a == [3, 2]! } diff --git a/vlib/v/tests/typeof_test.v b/vlib/v/tests/typeof_test.v index d5cfb0796c..98fc8de52b 100644 --- a/vlib/v/tests/typeof_test.v +++ b/vlib/v/tests/typeof_test.v @@ -28,8 +28,8 @@ fn test_type_constructors() { v := `c` assert typeof(&v).name == '&rune' assert typeof(&[v]).name == '&[]rune' - assert typeof([v]!!).name == '[1]rune' - assert typeof(&[v]!!).name == '&[1]rune' + assert typeof([v]!).name == '[1]rune' + assert typeof(&[v]!).name == '&[1]rune' assert typeof(&FooBar{}).name == '&FooBar' } @@ -74,7 +74,7 @@ fn test_typeof_on_sumtypes() { assert typeof(a).name == 'MySumType' assert typeof(b).name == 'MySumType' assert typeof(c).name == 'MySumType' - + assert a.str() == '32' assert b.str() == '123.' assert c.str() == 'FooBar' @@ -159,7 +159,7 @@ fn test_generic_type() { v := 5 assert type_name(v) == 'int' // assert type_name(&v) == '&int' - // assert type_name([v]!!) == '[1]int' + // assert type_name([v]!) == '[1]int' assert type_name([v]) == '[]int' assert type_name([[v]]) == '[][]int' assert type_name(FooBar{}) == 'FooBar'