From 827b0a8e23ffa8aa8cc0886f476d034b4a5148a6 Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Tue, 9 Sep 2025 22:25:07 +0800 Subject: [PATCH] workaround msvc int_min bug --- vlib/v/ast/comptime_const_values.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/ast/comptime_const_values.v b/vlib/v/ast/comptime_const_values.v index 798075b568..a28fafdb58 100644 --- a/vlib/v/ast/comptime_const_values.v +++ b/vlib/v/ast/comptime_const_values.v @@ -38,7 +38,8 @@ pub fn (val ComptTimeConstValue) i16() ?i16 { // int tries to return a `ComptTimeConstValue` as `int` type. pub fn (val ComptTimeConstValue) int() ?int { x := val.i64()? - if x > -2147483649 && x < 2147483648 { + // workaround msvc bug: if x > -2147483649 && x < 2147483648 { + if (x & 0xFFFFFFFF_00000000) == 0 { return int(x) } return none @@ -47,7 +48,8 @@ pub fn (val ComptTimeConstValue) int() ?int { // i32 tries to return a `ComptTimeConstValue` as `i32` type. pub fn (val ComptTimeConstValue) i32() ?i32 { x := val.i64()? - if x > -2147483649 && x < 2147483648 { + // workaround msvc bug: if x > -2147483649 && x < 2147483648 { + if (x & 0xFFFFFFFF_00000000) == 0 { return i32(x) } return none