[Issue 3219] New: Inaccurate std.conv.to!(numeric)(numeric) error messages
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 31 05:27:26 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3219
Summary: Inaccurate std.conv.to!(numeric)(numeric) error
messages
Product: D
Version: 2.031
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bugzilla at kyllingen.net
The errors raised by the numeric-numeric conversion function in std.conv are
inaccurate in two ways:
1. Both underflowing and overflowing conversions raise a
ConversionOverflowError, with the following respective messages presented to
the user:
std.conv.ConvOverflowError: Error: overflow Conversion underflow
std.conv.ConvOverflowError: Error: overflow Conversion overflow
2. Converting a floating-point NaN to an integer type gives an underflow error.
Suggestions for simple fixes:
1. At the very least, the "overflow" string which is added to both over- and
underflow errors should be removed from ConvOverflowError.
2. Put the following at the top of the "to" function definition:
static if (isFloatingPoint!S && !isFloatingPoint!T)
if (isNaN(value)) ConvOverflowError.raise("Cannot convert "
~S.stringof~".nan to "~T.stringof);
(Of course, it is arguable whether the slightly more accurate error message is
worth the performance penalty of the additional check...)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list