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

--- Comment #0 from Kenji Hara <> 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
    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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to