Summary: isNumeric("3.14w") is false.
           Product: D
           Version: future
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from David Simcha <> 2009-12-11 16:29:51 PST ---
import std.stdio, std.string;

void main() {
    writeln(isNumeric("3.14"));   // true
    writeln(isNumeric("3.14"w));  // false
    writeln(isNumeric("3.14"d));  // false

The problem is that we have isNumeric(...), which takes an argument using
runtime variadics and figures out whether it's numeric.  The default (if it's
not one of the listed types) is to return false.  However, the type list has
wchar[] and dchar[], not immutable(wchar)[] and immutable(dchar)[]:

    else if (_arguments[0] == typeid(wchar[]))
        return isNumeric(std.utf.toUTF8(va_arg!(wchar[])(_argptr)));
    else if (_arguments[0] == typeid(dchar[]))
        return isNumeric(std.utf.toUTF8(va_arg!(dstring)(_argptr)));

This leads to the default return false statement being executed.  IMHO the
solution is to just deprecate isNumeric(...), since it seems pretty useless
anyhow, and template isNumeric(string) and make it:

    isNumeric(String)(String s) if(isSomeString!(String))

This would also solve bug 3609.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to