diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 1795d7d289..2bb37eac6f 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -22,7 +22,7 @@ fn test_pointer() { } fn test_assign() { - arr := [2, 4, 8, 16, 32, 64, 128] + mut arr := [2, 4, 8, 16, 32, 64, 128] arr[0] = 2 arr[1] &= 255 @@ -99,7 +99,7 @@ struct K { } fn test_empty() { - mut chunks := []Chunk + mut chunks := []Chunk{} a := Chunk{} assert chunks.len == 0 chunks << a @@ -111,7 +111,7 @@ fn test_empty() { } fn test_push() { - mut a := []int + mut a := []int{} a << 1 a << 3 assert a[1] == 3 @@ -289,7 +289,7 @@ fn test_reverse() { for i, _ in d { assert d[i] == b[b.len - i - 1] } - e := []int + e := []int{} f := e.reverse() assert f.len == 0 } @@ -711,7 +711,7 @@ fn test_hex(){ } fn test_left_shift_precendence() { - mut arr := []int + mut arr := []int{} arr << 1 + 1 arr << 1 - 1 arr << 2 / 1 diff --git a/vlib/crypto/rand/rand.v b/vlib/crypto/rand/rand.v index c7f02c874b..c3bc04aa27 100644 --- a/vlib/crypto/rand/rand.v +++ b/vlib/crypto/rand/rand.v @@ -11,7 +11,7 @@ const ( // NOTE: temp until we have []bytes(buff) fn c_array_to_bytes_tmp(len int, buffer voidptr) []byte { - mut arr := []byte + mut arr := []byte{} arr = make(len, 1, 1) arr.data = buffer /* diff --git a/vlib/crypto/rand/rand_test.v b/vlib/crypto/rand/rand_test.v index 0d76c5a6b4..41e2b199f5 100644 --- a/vlib/crypto/rand/rand_test.v +++ b/vlib/crypto/rand/rand_test.v @@ -31,7 +31,7 @@ fn test_crypto_rand_read() { fn test_crypto_rand_int_u64() { max := u64(160) - mut unique := []int + mut unique := []int{} for _ in 0..80 { r := rand.int_u64(max) or { assert false diff --git a/vlib/crypto/rand/utils.v b/vlib/crypto/rand/utils.v index 27091115b2..14cfdb84c2 100644 --- a/vlib/crypto/rand/utils.v +++ b/vlib/crypto/rand/utils.v @@ -4,10 +4,8 @@ module rand -import( - math.bits - encoding.binary -) +import math.bits +import encoding.binary pub fn int_u64(max u64) ?u64 { bitlen := bits.len_64(max) diff --git a/vlib/rand/rand.v b/vlib/rand/rand.v index d7126510f9..9ccd681b40 100644 --- a/vlib/rand/rand.v +++ b/vlib/rand/rand.v @@ -16,7 +16,7 @@ pub fn next(max int) int { // rand_r returns a pseudo-random number; // writes a result value to the seed argument. -pub fn rand_r(seed mut int) int { +pub fn rand_r(seed &int) int { ns := *seed * 1103515245 + 12345 (*seed) = ns return ns & 0x7fffffff diff --git a/vlib/v/tests/map_to_string_test.v b/vlib/v/tests/map_to_string_test.v index 7af0b3a80a..4bb27921a4 100644 --- a/vlib/v/tests/map_to_string_test.v +++ b/vlib/v/tests/map_to_string_test.v @@ -5,21 +5,26 @@ struct Test { } fn test_interpolation_map_to_string() { - a := map[string]string + if true { + + } + // + else{} + mut a := map[string]string a['1'] = 'one' a['2'] = 'two' a['3'] = 'three' assert '$a' == 'map_string_string{1: one, 2: two, 3: three}' - b := map[string]int + mut b := map[string]int b['1'] = 1 b['2'] = 2 b['3'] = 3 assert '$b' == 'map_string_int{1: 1, 2: 2, 3: 3}' - c := map[string]bool + mut c := map[string]bool c['1'] = true c['2'] = false assert '$c' == 'map_string_bool{1: true, 2: false}' - d := map[string]Test + mut d := map[string]Test d['1'] = Test{true, 0, 'abc'} d['2'] = Test{true, 1, 'def'} d['3'] = Test{false, 2, 'ghi'} diff --git a/vlib/v/tests/nested_map_test.v b/vlib/v/tests/nested_map_test.v index 9a4574be7e..92f3a1f282 100644 --- a/vlib/v/tests/nested_map_test.v +++ b/vlib/v/tests/nested_map_test.v @@ -1,5 +1,8 @@ fn test_nested_maps() { - x := map[string]map[string]int + if true{} + // + else{} + mut x := map[string]map[string]int x["a"] = map[string]int assert x["a"]["b"] == 0 x["a"]["b"] = 5