Thread overview
[Issue 3219] New: Inaccurate std.conv.to!(numeric)(numeric) error messages
July 31, 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@puremagic.com
        ReportedBy: bugzilla@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: -------
July 31, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3219


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 28, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3219


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------