Bug 11079 – Attributes for template functions should be visible when used with traits

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-20T14:36:00Z
Last change time
2014-04-27T20:03:43Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-09-20T14:36:56Z
----- interface A { static void foo(B obj) { // ok static assert(__traits(isStaticFunction, __traits(getMember, obj, "foo"))); } static void bar(T)(T obj) { // fails static assert(__traits(isStaticFunction, __traits(getMember, obj, "bar"))); } } class B : A { } void main() { B b = new B; b.foo(b); b.bar(b); } ----- I think this is the same symptom as in http://d.puremagic.com/issues/show_bug.cgi?id=194, and particularly Walter's comment http://d.puremagic.com/issues/show_bug.cgi?id=194#c1. However, the templated function 'bar' is static regardless of what it's instantiated with, so the traits should likely be able to work with it.
Comment #1 by andrej.mitrovich — 2013-09-20T14:37:25Z
Issue was found by CounterPillow from IRC, filing on his behalf.
Comment #2 by andrej.mitrovich — 2014-04-27T20:03:43Z
Walter's comment from here: https://github.com/D-Programming-Language/dmd/pull/3501#issuecomment-41484446 > Should it work? > > No. It's not a function until it is instantiated. In fact, the attributes cannot be determined until it is instantiated, because attributes are inferred on function templates. So I'm marking this as invalid. But maybe a set of better docs need to be made for the traits page.