Bug 5425 – __traits(compiles, ...) fails when given a template property function without parens
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-01-07T21:13:00Z
Last change time
2012-05-30T22:01:23Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2011-01-07T21:13:49Z
This fails to compile:
struct S
{
@property T func(T)()
{
return T.init;
}
}
void main()
{
S s;
s.func!int;
static assert(__traits(compiles, s.func!int));
}
and gives this error:
test.d(13): Error: static assert (__traits(compiles,s.func!(int))) is false
If you change s.func!int to s.func!int() in the __traits statement, then it compiles. But while the program itself can handle s.func!int, __traits can't. It needs the parens. And as soon as properties are fixed so that they _can't_ be called with parens, then this will be that much more of a problem.