December 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7143

           Summary: [CTFE] cannot compare class references with "is"
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: r.sagitario@gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario@gmx.de> 2011-12-20 06:58:20 PST ---
Comparing class references with null or other classes causes an error in CTFE, e.g.:

module test;

class C
{
    int x;
}

int getA()
{
    C c = new C;
    if(c is null)
        return -1;
    return c.x;
}

static assert(getA() == 0);


Compiling with "dmd -c test.d" yields:
test.d(11): Error: cannot compare C(0) at compile time
test.d(16):        called from here: getA()
test.d(16):        while evaluating: static assert(getA() == 0)

if you use "if(c)" instead of "if(c is null)", the error itself disappears,
there is only the call stack left:
test.d(16):        called from here: getA()
test.d(16):        while evaluating: static assert(getA() == 0)

Using "if(!c)" seems to work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7143


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-12-21 15:24:10 PST ---
https://github.com/D-Programming-Language/dmd/commit/767708299a408b4a234ee9ad4f45b0e6e0c21e6d

https://github.com/D-Programming-Language/dmd/commit/13195c39ae3e3788c559d8e88d3203371e43f029

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