Commit ee0dbadd
ee0dbadde3b1Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: unbox a poly ndigits arg in Float#round/ceil/floor/truncate
A non-literal ndigits widened to poly was cast straight to double
(pow(10, (double)(<sp_RbVal>))), an aggregate-to-float error. Route it
through emit_int_expr so a poly arg is unboxed to int first. Fixes
float_round_nonliteral.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- ee0dbadde3b1
- Parent
- 1cfd2821dd3e
src/codegen_call.cmodifiedView file
@@ -2472,7 +2472,7 @@
24722472
any n (n<=0 yields a whole number, still Float -- class-only divergence). */24732473
int tf = ++g_tmp;24742474
buf_printf(b, "({ double _t%d = pow(10, (double)(", tf);2475-
emit_expr(c, argv[0], b);2475+
emit_int_expr(c, argv[0], b); /* ndigits: unbox a poly arg to int */24762476
buf_printf(b, ")); %s((%s) * _t%d) / _t%d; })", cfn, r, tf, tf);24772477
}24782478
else if (ndig > 0)