www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra 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: -------
Aug 24 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10878


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning still-hidden.de


--- Comment #1 from Henning Pohl <henning still-hidden.de> 2013-08-24 08:26:05
PDT ---
I think this is a dupe of issue 10329. I have got a PR off the ground but I
don't know how to fix those linker errors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10878


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from monarchdodra gmail.com 2013-08-24 10:24:04 PDT ---
*** This issue has been marked as a duplicate of issue 10329 ***

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