[Issue 7452] New: Function using enforce() cannot be inferred as @safe because of the lazy argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 6 13:22:42 PST 2012


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

           Summary: Function using enforce() cannot be inferred as @safe
                    because of the lazy argument
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: kennytm at gmail.com


--- Comment #0 from kennytm at gmail.com 2012-02-06 13:22:40 PST ---
Test case:

----------------------------------
import std.exception;
int f7452()(int x)
{
   enforce(x > 0);
   return x;
}
void g7452() @safe pure
{
   assert(4 == f7452(4));
}
----------------------------------

This caused error:

    Error: safe function 'g7452' cannot call system function 'f7452'



This is because of the lazy argument, as shown with this minimal D-only test
case:

----------------------------------
void e7452b(int, lazy int) pure nothrow @safe {}
int f7452b()(int x)
{
   e7452b(x, 0);
   return x;
}
void g7452b() pure nothrow @safe
{
   assert(4 == f7452b(4));
}
----------------------------------

-- 
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