[Issue 10878] New: Non-template structs declared inside templates are not inferred

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 24 04:26:56 PDT 2013


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

           Summary: Non-template structs declared inside templates are not
                    inferred
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2013-08-24 04:26:54 PDT ---
//----
auto foo(T)(T t)
{
    static struct Result
    {
        this(T t)
        {}
    }
    return Result(t);
}

void main() @safe pure
{
    foo(5);
}
//----
Error: pure function 'D main' cannot call impure function 'hello.foo!int.foo'
Error: safe function 'D main' cannot call system function 'hello.foo!int.foo'
//----

Since `struct` is declared in a templated function, then all its functions'
attributes should be infered.

I *think* this is a bug entry? If not, then it should be an enhancement request
that the language behave that way.

I'm marking as "Major", because a *lot* of phobos ranges are implemented that
way. Because of this, trivial operations, such as "chain([0 .. 2], [3 .. 4])",
are considered throwing, unsafe and impure.

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