[Issue 7401] New: Pure contracts Unnecessarily strict

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 30 14:23:54 PST 2012


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

           Summary: Pure contracts Unnecessarily strict
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rtcvb32 at yahoo.com


--- Comment #0 from Era Scarecrow <rtcvb32 at yahoo.com> 2012-01-30 14:23:53 PST ---
The compiler complaining to me that my function isn't 'pure' by calling a
non-pure function, specifically to!string(). 

However the unpure functions used are only accessed in the contracts (and only
if it failed). The contracts shouldn't be considered as part of the pure
contract. This is because they are totally excluded during the release builds
(and shouldn't have any side effects anyways).



Error: pure function 'offset' cannot call impure function 'to'  


struct X
{
    int size;

...

    const pure int offset(int field)
    out(o)
    {
        assert(o >= 0, "Negative value! Check structure:" ~ to!string(size) ~
"\n");
    }
    body { ... } 
}

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


More information about the Digitalmars-d-bugs mailing list