LibWasm: Cast to long double before checking if trunactions is in range

I found that this fixes some precision issues while comparing to values
on the edge of the limits.

Fixes 6 tests in conversions.wast on WPT.
This commit is contained in:
Undefine 2025-10-19 16:35:13 +02:00 committed by Ali Mohammad Pur
parent 11a1e97e40
commit 692195ae88

View File

@ -1046,7 +1046,7 @@ struct CheckedTruncate {
// FIXME: This function assumes that all values of ResultT are representable in Lhs
// the assumption comes from the fact that this was used exclusively by LibJS,
// which only considers values that are all representable in 'double'.
if (!AK::is_within_range<ResultT>(truncated))
if (!AK::is_within_range<ResultT>(static_cast<long double>(truncated)))
return "Truncation out of range"sv;
return static_cast<ResultT>(truncated);