From 1411c2710b03c53fa0de08d39c656d98721783f6 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 13 Dec 2025 14:14:01 +0200 Subject: [PATCH] ci: run `v -W -silent test-self vlib` on linux, so deprecations/warnings introduced in PRs, can fail (and be fixed) earlier (#25955) --- ci/linux_ci.vsh | 4 ++-- ...e_compile_warn_with_string_interp_test.out | 21 +++++++++++++++++++ ...e_compile_warn_with_string_interp_test.vv} | 0 .../type_alias_of_pointer_types_test.v | 2 +- .../builtin_maps/map_complex_array_test.v | 10 +++++---- .../string_interpolation_test.v | 10 +++++---- vlib/v/tests/c_const_u8_test.v | 2 +- .../tests/c_function_mut_param/code_test.c.v | 2 +- .../c_function_mut_param/option_args_test.c.v | 2 +- vlib/v/tests/c_structs/cstruct_ref_test.c.v | 2 +- .../v/tests/fns/fn_call_interface_args_test.v | 4 ++-- .../fn_call_with_newline_opening_brace_test.v | 6 ++---- .../go_call_fn_with_anon_fn_array_arg_test.v | 2 +- ...eric_fn_returning_option_and_result_test.v | 6 +++--- .../generics_call_with_reference_arg_test.v | 2 +- .../tests/loops/for_in_map_of_pointers_test.v | 2 +- vlib/v/tests/loops/for_in_ref_map_test.v | 4 ++-- vlib/v/tests/match_or_expr_test.v | 2 +- vlib/v/tests/pointers/ptr_arithmetic_test.v | 8 +++---- vlib/v/tests/pointers/unsafe_test.c.v | 6 +++--- vlib/v/tests/sumtypes/sumtype_ptr_ptr_test.v | 4 ++-- 21 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.out rename vlib/v/{tests/comptime/comptime_compile_warn_with_string_interp_test.v => checker/tests/comptime_compile_warn_with_string_interp_test.vv} (100%) diff --git a/ci/linux_ci.vsh b/ci/linux_ci.vsh index 458bf12d6..82ae4e722 100644 --- a/ci/linux_ci.vsh +++ b/ci/linux_ci.vsh @@ -21,7 +21,7 @@ fn test_pure_v_math_module() { fn self_tests() { if common.is_github_job { - exec('v -silent test-self vlib') + exec('v -W -silent test-self vlib') } else { exec('v -progress test-self vlib') } @@ -29,7 +29,7 @@ fn self_tests() { fn build_examples() { if common.is_github_job { - exec('v build-examples') + exec('v -W build-examples') } else { exec('v -progress build-examples') } diff --git a/vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.out b/vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.out new file mode 100644 index 000000000..7ab32d365 --- /dev/null +++ b/vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.vv:6:3: warning: invalid type i8 5 + 4 | $if T is i8 { + 5 | assert typeof[T]().name == typeof[i8]().name + 6 | $compile_warn('invalid type ${T.name} ${T.idx}') + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 7 | return 1 + 8 | } +vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.vv:16:3: warning: invalid type i8 5, i16 6 + 14 | assert typeof[T]().name == typeof[i8]().name + 15 | assert typeof[R]().name == typeof[i16]().name + 16 | $compile_warn('invalid type ${T.name} ${T.idx}, ${R.name} ${R.idx}') + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 17 | return 1 + 18 | } +vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.vv:27:3: warning: invalid type i8 5, i16 6, i32 7 + 25 | assert typeof[R]().name == typeof[i16]().name + 26 | assert typeof[E]().name == typeof[i32]().name + 27 | $compile_warn('invalid type ${T.name} ${T.idx}, ${R.name} ${R.idx}, ${E.name} ${E.idx}') + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 28 | return 1 + 29 | } diff --git a/vlib/v/tests/comptime/comptime_compile_warn_with_string_interp_test.v b/vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.vv similarity index 100% rename from vlib/v/tests/comptime/comptime_compile_warn_with_string_interp_test.v rename to vlib/v/checker/tests/comptime_compile_warn_with_string_interp_test.vv diff --git a/vlib/v/tests/aliases/type_alias_of_pointer_types_test.v b/vlib/v/tests/aliases/type_alias_of_pointer_types_test.v index 4d0b904b2..c452769ce 100644 --- a/vlib/v/tests/aliases/type_alias_of_pointer_types_test.v +++ b/vlib/v/tests/aliases/type_alias_of_pointer_types_test.v @@ -86,7 +86,7 @@ fn test_alias_of_pointer() { println('Actual handle value is: ${handle}') println('Memory address of handle is: ${&handle}') - example(handle) + unsafe { example(handle) } assert '${handle}' == '0' } diff --git a/vlib/v/tests/builtin_maps/map_complex_array_test.v b/vlib/v/tests/builtin_maps/map_complex_array_test.v index b7da5707a..98818d820 100644 --- a/vlib/v/tests/builtin_maps/map_complex_array_test.v +++ b/vlib/v/tests/builtin_maps/map_complex_array_test.v @@ -12,8 +12,10 @@ fn test_map_complex_array() { } arr := [instr] map1['Hello'] = arr - map1['Hello'][0].a = 2 - println(map1['Hello'][0].a) - assert map1['Hello'][0].a == 2 - assert map1['Hello'][0].b == 2 + unsafe { + map1['Hello'][0].a = 2 + println(map1['Hello'][0].a) + assert map1['Hello'][0].a == 2 + assert map1['Hello'][0].b == 2 + } } diff --git a/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v b/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v index 65525097a..9aefd13a5 100644 --- a/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v +++ b/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v @@ -97,10 +97,12 @@ fn test_inttypes_string_interpolation() { ui := u32(3421958087) // 0xCBF6 EFC7 vp := voidptr(ui) mut bp := &u8(unsafe { nil }) - $if x64 { - bp = &u8(15541149836) // 0x3 9E53 208C - } $else { - bp = &u8(3541149836) // 0xD311 A88C + unsafe { + $if x64 { + bp = &u8(15541149836) // 0x3 9E53 208C + } $else { + bp = &u8(3541149836) // 0xD311 A88C + } } l := i64(-7694555558525237396) ul := u64(17234006112912956370) diff --git a/vlib/v/tests/c_const_u8_test.v b/vlib/v/tests/c_const_u8_test.v index 4fce58501..4dd1736d4 100644 --- a/vlib/v/tests/c_const_u8_test.v +++ b/vlib/v/tests/c_const_u8_test.v @@ -1,4 +1,4 @@ -import net +import net as _ const C.AF_UNIX u16 diff --git a/vlib/v/tests/c_function_mut_param/code_test.c.v b/vlib/v/tests/c_function_mut_param/code_test.c.v index bbbe4444f..ae121a7ff 100644 --- a/vlib/v/tests/c_function_mut_param/code_test.c.v +++ b/vlib/v/tests/c_function_mut_param/code_test.c.v @@ -5,7 +5,7 @@ module main fn C.mut_arg(key &u8, mut val usize) fn test_c_function_mut_param() { - key := &u8(1) + key := unsafe { &u8(1) } mut val := usize(1) C.mut_arg(key, mut &val) assert val == usize(5) diff --git a/vlib/v/tests/c_function_mut_param/option_args_test.c.v b/vlib/v/tests/c_function_mut_param/option_args_test.c.v index 740e1acfd..5042128a6 100644 --- a/vlib/v/tests/c_function_mut_param/option_args_test.c.v +++ b/vlib/v/tests/c_function_mut_param/option_args_test.c.v @@ -5,7 +5,7 @@ module main fn C.mut_arg(&u8, mut val usize) fn test_c_function_mut_param() { - key := &u8(1) + key := unsafe { &u8(1) } mut val := usize(1) C.mut_arg(key, mut &val) assert val == usize(5) diff --git a/vlib/v/tests/c_structs/cstruct_ref_test.c.v b/vlib/v/tests/c_structs/cstruct_ref_test.c.v index aac49be86..22fb4df4d 100644 --- a/vlib/v/tests/c_structs/cstruct_ref_test.c.v +++ b/vlib/v/tests/c_structs/cstruct_ref_test.c.v @@ -16,7 +16,7 @@ fn (it C.MyCStruct) wrap() MyWrapper { fn test_main() { dump(C.MyCStruct{ - data: &u8(123) + data: unsafe { &u8(123) } }.wrap()) assert true } diff --git a/vlib/v/tests/fns/fn_call_interface_args_test.v b/vlib/v/tests/fns/fn_call_interface_args_test.v index f5e44138f..adec8ef9b 100644 --- a/vlib/v/tests/fns/fn_call_interface_args_test.v +++ b/vlib/v/tests/fns/fn_call_interface_args_test.v @@ -1,8 +1,8 @@ interface Foo {} fn has_interface_args(mut a Foo, b &Foo, c Foo) { - assert a == &Foo(1) - assert b == &Foo(1) + assert a == unsafe { &Foo(1) } + assert b == unsafe { &Foo(1) } assert c == Foo(1) } diff --git a/vlib/v/tests/fns/fn_call_with_newline_opening_brace_test.v b/vlib/v/tests/fns/fn_call_with_newline_opening_brace_test.v index 51a905282..649fa1684 100644 --- a/vlib/v/tests/fns/fn_call_with_newline_opening_brace_test.v +++ b/vlib/v/tests/fns/fn_call_with_newline_opening_brace_test.v @@ -34,16 +34,14 @@ fn new_address(cfg AddressConfig) &Address } } -const ( - default_address = new_address(AddressConfig{}) - initialized_address = new_address +const default_address = new_address(AddressConfig{}) +const initialized_address = new_address ( street: '0987 tluafeD tS' city: 'ytiC etirovaF rouY' state: 'ynA eB dluoC' zip: 24 ) -) // vfmt on fn (a Address) str() string { diff --git a/vlib/v/tests/fns/go_call_fn_with_anon_fn_array_arg_test.v b/vlib/v/tests/fns/go_call_fn_with_anon_fn_array_arg_test.v index 78291d18a..59c9f737b 100644 --- a/vlib/v/tests/fns/go_call_fn_with_anon_fn_array_arg_test.v +++ b/vlib/v/tests/fns/go_call_fn_with_anon_fn_array_arg_test.v @@ -6,7 +6,7 @@ type Func = fn () int fn handle_fns(fns []Func, mut w MyInterface) {} fn test_main() { - mut w := &MyInterface(123) + mut w := unsafe { &MyInterface(123) } spawn handle_fns([], mut w) assert true } diff --git a/vlib/v/tests/generics/generic_fn_returning_option_and_result_test.v b/vlib/v/tests/generics/generic_fn_returning_option_and_result_test.v index 78850d08f..f495fd363 100644 --- a/vlib/v/tests/generics/generic_fn_returning_option_and_result_test.v +++ b/vlib/v/tests/generics/generic_fn_returning_option_and_result_test.v @@ -7,7 +7,7 @@ fn get_value_result[T]() !T { } fn test_generic_function_that_returns_an_option() { - value := get_value[&int]() or { &int(0) } + value := get_value[&int]() or { unsafe { &int(0) } } assert value == unsafe { nil } sval := get_value[string]() or { 'abc' } assert sval == 'abc' @@ -20,6 +20,6 @@ fn test_generic_function_that_returns_an_error() { assert sval == 'xyz' ival := get_value_result[int]() or { 456 } assert ival == 456 - pval := get_value_result[&int]() or { &int(789) } - assert u64(pval) == u64(&int(789)) + pval := get_value_result[&int]() or { unsafe { &int(789) } } + assert u64(pval) == u64(unsafe { &int(789) }) } diff --git a/vlib/v/tests/generics/generics_call_with_reference_arg_test.v b/vlib/v/tests/generics/generics_call_with_reference_arg_test.v index 54c63d2e5..5335b8cbf 100644 --- a/vlib/v/tests/generics/generics_call_with_reference_arg_test.v +++ b/vlib/v/tests/generics/generics_call_with_reference_arg_test.v @@ -10,7 +10,7 @@ fn (mut s MyStruct[T]) add(e &T) bool { } fn fill(mut s MyStruct[i64]) { - s.add(&i64(123)) + s.add(unsafe { &i64(123) }) } fn test_generics_call_with_reference_arg() { diff --git a/vlib/v/tests/loops/for_in_map_of_pointers_test.v b/vlib/v/tests/loops/for_in_map_of_pointers_test.v index 32c862993..aa351ee50 100644 --- a/vlib/v/tests/loops/for_in_map_of_pointers_test.v +++ b/vlib/v/tests/loops/for_in_map_of_pointers_test.v @@ -5,7 +5,7 @@ fn test_for_in_map_of_pointers() { mut my_map := map[int]&int{} my_map[0] = pi for k, wrong_value in my_map { - good_value := my_map[k] + good_value := unsafe { my_map[k] } println('k: ${k} \n wrong_value: ${wrong_value} \n good_value: ${good_value}') up_good_value := voidptr(good_value).hex_full() up_wrong_value := voidptr(wrong_value).hex_full() diff --git a/vlib/v/tests/loops/for_in_ref_map_test.v b/vlib/v/tests/loops/for_in_ref_map_test.v index 4f20db6e8..38f2321eb 100644 --- a/vlib/v/tests/loops/for_in_ref_map_test.v +++ b/vlib/v/tests/loops/for_in_ref_map_test.v @@ -17,7 +17,7 @@ fn test_for_in_ref_val_ref_map() { } for k, val in &mp { - assert voidptr(val) == voidptr(expects[k]) + assert voidptr(val) == voidptr(unsafe { expects[k] }) } assert rets == expects } @@ -42,7 +42,7 @@ fn test_for_in_ref_val_ref_map_ident() { } for k, val in mp { - assert voidptr(val) == voidptr(expects[k]) + assert voidptr(val) == voidptr(unsafe { expects[k] }) } assert rets == expects } diff --git a/vlib/v/tests/match_or_expr_test.v b/vlib/v/tests/match_or_expr_test.v index af90f6549..e9634bdbe 100644 --- a/vlib/v/tests/match_or_expr_test.v +++ b/vlib/v/tests/match_or_expr_test.v @@ -1,5 +1,5 @@ struct Foo { - option ?int = none + option ?int = unsafe { none } } fn test_main() { diff --git a/vlib/v/tests/pointers/ptr_arithmetic_test.v b/vlib/v/tests/pointers/ptr_arithmetic_test.v index 92072c561..8ab1356ab 100644 --- a/vlib/v/tests/pointers/ptr_arithmetic_test.v +++ b/vlib/v/tests/pointers/ptr_arithmetic_test.v @@ -20,20 +20,20 @@ fn test_ptr_arithmetic() { fn test_ptr_arithmetic_over_byteptr() { // byteptr, voidptr, charptr are handled differently - mut q := &u8(10) + mut q := unsafe { &u8(10) } unsafe { q -= 2 q = q + 1 } - assert u64(q) == u64(&u8(9)) + assert u64(q) == u64(unsafe { &u8(9) }) s := unsafe { q - 1 } - assert u64(s) == u64(&u8(8)) + assert u64(s) == u64(unsafe { &u8(8) }) unsafe { q++ q++ q-- } - assert u64(q) == u64(&u8(10)) + assert u64(q) == u64(unsafe { &u8(10) }) } struct Abc { diff --git a/vlib/v/tests/pointers/unsafe_test.c.v b/vlib/v/tests/pointers/unsafe_test.c.v index 8f1f05efc..ac64c57d4 100644 --- a/vlib/v/tests/pointers/unsafe_test.c.v +++ b/vlib/v/tests/pointers/unsafe_test.c.v @@ -24,12 +24,12 @@ fn test_double_ptr() { assert x == &j } // /////// - mut x := &int(0) + mut x := unsafe { &int(0) } unsafe { mut p := &x (*p) = &int(1) } - assert ptr_str(x) == ptr_str(&int(1)) + assert ptr_str(x) == ptr_str(unsafe { &int(1) }) } fn test_ptr_infix() { @@ -55,7 +55,7 @@ fn test_funcs() { fn test_if_expr_unsafe() { i := 4 ii := 123 - p := if true { unsafe { &i } } else { unsafe { &ii } } + p := if unsafe { true } { unsafe { &i } } else { unsafe { &ii } } assert *p == 4 } diff --git a/vlib/v/tests/sumtypes/sumtype_ptr_ptr_test.v b/vlib/v/tests/sumtypes/sumtype_ptr_ptr_test.v index 2b66fe07c..3ff730df1 100644 --- a/vlib/v/tests/sumtypes/sumtype_ptr_ptr_test.v +++ b/vlib/v/tests/sumtypes/sumtype_ptr_ptr_test.v @@ -23,6 +23,6 @@ fn test_main() { assert false } - assert typeof(command_arr_el_ptr) == 'Call' - assert typeof(command_arr_ptr) == '[]&Command' + assert unsafe { typeof(command_arr_el_ptr) == 'Call' } + assert unsafe { typeof(command_arr_ptr) == '[]&Command' } } -- 2.39.5