www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11135] New: Nullable(T, T nullValue) does not support NaN

http://d.puremagic.com/issues/show_bug.cgi?id=11135

           Summary: Nullable(T, T nullValue) does not support NaN
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: anoneuron gmail.com



A little unsurprising, but quite annoying. See this simple test case:

void main() {
    import std.stdio;
    import std.typecons;

    Nullable!(float, float.nan) Value;
    writeln(Value.isNull, " <- should be true");
    Value.nullify();
    writeln(Value.isNull, " <- should be true");
};

Value.isNull always evaluates to false.

A simple patch in typecons.d seems to resolve the issue,
in the isNull function on line 1478, replace
    return _value == nullValue;
with
    return _value is nullValue;
I don't *think* this change could cause other issues, but I'm not completely
certain.

Tested using DMD v2.063.2 on WinXP.

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