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

           Summary: Pure inference makes inconsistent result
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: k.hara...@gmail.com


--- Comment #0 from Kenji Hara <k.hara...@gmail.com> 2011-11-25 22:23:44 PST ---
Pure/nothrow/@safe inference with template function is shallow.
It does not affect to nested non-template struct member functions.

But in following code, map template function inferred as pure in some cases.
This is pure inference bug.

template map(fun...) if (fun.length >= 1)
{
    auto map()
    {
        struct Result {
            this(int dummy){}   // impure member function
        }
        return Result(0);   // impure call
    }
}
int foo(immutable int x) pure nothrow { return 1; }
void main() pure
{
    int bar(immutable int x) pure nothrow { return 1; }

    static assert(!__traits(compiles, map!((){})()));   // should pass, but
fails
    static assert(!__traits(compiles, map!q{ 1 }()));   // pass, OK
    static assert(!__traits(compiles, map!foo()));      // pass, OK
    static assert(!__traits(compiles, map!bar()));      // should pass, but
fails
}

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

Reply via email to