www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10452] New: CTFE: if(x is null) Error: cannot compare __lambda1 at compile time

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10452

           Summary: CTFE: if(x is null) Error: cannot compare __lambda1 at
                    compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: destructionator gmail.com



11:31:05 PDT ---
string foo(bool delegate() bar) {
        return (bar !is null) ? "0" : "1";
}

void main() {
        enum there = foo(() => true);
}

test12.d(2): Error: cannot compare __lambda1 at compile time
test12.d(7):        called from here: foo(bool()
{
return true;
}
)


I understand generally not being able to compare pointers in CTFE, but I think
is null and !is null should be permitted wherever possible because that's
something I do a lot: if(dg is null) return some_default; else return dg(); and
it would be cool if it worked in ctfe too.

Failed on dmd v2.063

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 23 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10452


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE, rejects-valid
            Summary|CTFE: if(x is null) Error:  |CTFE: Cannot compare
                   |cannot compare __lambda1 at |delegates with == or 'is'
                   |compile time                |
           Severity|enhancement                 |normal



This isn't an enhancement, it's a bug. All forms of delegate (null, delegate
literal, nested function, struct member, class member) should be comparable
with == and 'is'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10452




https://github.com/D-Programming-Language/dmd/pull/2360

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10452




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/48385f97a2604c87fed590a1b091c387183a5167
Fix issue 10452 cannot compare delegates in CTFE

Support == and 'is' for delegates.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 21 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10452


Walter Bright <bugzilla digitalmars.com> changed:

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


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