Bug 10878 – Non-template structs declared inside templates are not inferred
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-24T04:26:00Z
Last change time
2015-06-09T05:14:43Z
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2013-08-24T04:26:54Z
//----
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.
Comment #1 by henning — 2013-08-24T08:26:05Z
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.
Comment #2 by monarchdodra — 2013-08-24T10:24:04Z
*** This issue has been marked as a duplicate of issue 10329 ***