You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can_cast_types reports string → negative-scale decimal as supported, but cast always errors #10792
The arm is cast/mod.rs:209-213 — Utf8View | Utf8 | LargeUtf8 to any Decimal* is an unconditional true. The rejection is at cast/decimal.rs:798.
The float path you're contrasting with does handle negative scale: cast/mod.rs:375 branches on scale < 0 and divides by 10^-scale. The string path has no divide because parse_decimal has none, which is #10791. So the two ways to close this aren't equivalent — narrowing can_cast_types to scale >= 0 restores the contract but leaves string to negative-scale decimal unsupported, whereas making the cast work means #10791 lands first. Probably worth settling which one is wanted before someone starts, since #10791 is already taken.
The same arm also over-reports for scale > MAX_SCALE:
can_cast_types(Utf8, Decimal128(10, 40)) == true
cast Utf8 -> Err "Cannot cast string to decimal greater than maximum scale 38"
cast Float64 -> Err "scale 40 is greater than max 38"
That one has only a single resolution, since no source type supports it. Same arm, so whatever lands here should probably cover both.
Activity
neilconway commentedon Aug 21, 2026
take
Lstarsky0 commentedon Aug 23, 2026
The arm is
cast/mod.rs:209-213—Utf8View | Utf8 | LargeUtf8to anyDecimal*is an unconditionaltrue. The rejection is atcast/decimal.rs:798.The float path you're contrasting with does handle negative scale:
cast/mod.rs:375branches onscale < 0and divides by10^-scale. The string path has no divide becauseparse_decimalhas none, which is #10791. So the two ways to close this aren't equivalent — narrowingcan_cast_typestoscale >= 0restores the contract but leaves string to negative-scale decimal unsupported, whereas making the cast work means #10791 lands first. Probably worth settling which one is wanted before someone starts, since #10791 is already taken.The same arm also over-reports for
scale > MAX_SCALE:That one has only a single resolution, since no source type supports it. Same arm, so whatever lands here should probably cover both.
Consolidate string-to-decimal parsing into a single code path
fix: Consolidate string-to-decimal parsing into a single code path (#…
fix: Consolidate string-to-decimal parsing into a single code path (a…
fix: Consolidate string-to-decimal parsing into a single code path (a…
fix: Consolidate string-to-decimal parsing into a single code path (a…