[Issue 10329] New: Attributes not inferred for indirectly templated methods
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 10 23:04:34 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329
Summary: Attributes not inferred for indirectly templated
methods
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: blocker
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bugzilla at kyllingen.net
--- Comment #0 from Lars T. Kyllingstad <bugzilla at kyllingen.net> 2013-06-10 23:04:32 PDT ---
Currently, attributes such as @safe, pure and nothrow are automatically
inferred for function templates. They should also be inferred for methods of
struct/class templates and for Voldemort types.
Test case:
struct S1
{
void foo(T)() { }
}
struct S2(T)
{
void foo() { }
}
auto makeS3(T)()
{
struct S3
{
void foo() { }
}
return S3();
}
void main() @safe pure nothrow
{
// Works
S1 s1;
s1.foo!int();
// Compilation failure
S2!int s2;
s2.foo();
// Compilation failure
auto s3 = makeS3!int();
s3.foo();
}
This currently prevents large parts of Phobos from being used in
@safe/pure/nothrow contexts, and it prevents parts of Phobos from being marked
as such. It also blocks some changes to std.path that I have in the pipeline,
because I want to reimplement a function in terms of std.algorithm functions
without removing its current attributes (as this would be a breaking change).
A workaround (which is *not* feasible for use in Phobos) is to make the methods
themselves trivial templates:
struct S2(T)
{
void foo()() { }
}
--
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