From 2687af210f64f9f7443fddae94909eed44ce1a0a Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 23:16:01 +0300 Subject: [PATCH] checker: fix silent conversion of u64 to f64 (fixes #21778) --- vlib/v/checker/tests/or_block_u64_to_f64_err.out | 7 +++++++ vlib/v/checker/tests/or_block_u64_to_f64_err.vv | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 vlib/v/checker/tests/or_block_u64_to_f64_err.out create mode 100644 vlib/v/checker/tests/or_block_u64_to_f64_err.vv diff --git a/vlib/v/checker/tests/or_block_u64_to_f64_err.out b/vlib/v/checker/tests/or_block_u64_to_f64_err.out new file mode 100644 index 000000000..be9fb9684 --- /dev/null +++ b/vlib/v/checker/tests/or_block_u64_to_f64_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/or_block_u64_to_f64_err.vv:5:41: error: wrong return type `u64` in the `or {}` block, expected `f64` + 3 | fn main() { + 4 | mut num := f64(0.0) + 5 | num = strconv.atof64('x') or { strconv.double_minus_infinity } + | ~~~~~~~~~~~~~~~~~~~~~ + 6 | println(num) + 7 | } diff --git a/vlib/v/checker/tests/or_block_u64_to_f64_err.vv b/vlib/v/checker/tests/or_block_u64_to_f64_err.vv new file mode 100644 index 000000000..1f3a70765 --- /dev/null +++ b/vlib/v/checker/tests/or_block_u64_to_f64_err.vv @@ -0,0 +1,7 @@ +import strconv + +fn main() { + mut num := f64(0.0) + num = strconv.atof64('x') or { strconv.double_minus_infinity } + println(num) +} -- 2.39.5