__traits(getAttributes, ...) gets attributes for the first overload only

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 5 15:23:14 PST 2015


On 12/5/15 6:07 PM, Andrei Alexandrescu wrote:
> On 12/5/15 6:04 PM, Steven Schveighoffer wrote:
>> On 12/5/15 5:42 PM, Andrei Alexandrescu wrote:
>>> On 12/05/2015 04:30 PM, Adam D. Ruppe wrote:
>>>> On Saturday, 5 December 2015 at 20:44:40 UTC, Andrei Alexandrescu
>>>> wrote:
>>>>> Working on the big-oh thing I noticed that for an overloaded function,
>>>>> __traits(getAttributes, ...) applied to overloaded functions only
>>>>> fetches attributes for the first syntactically present overload. Bug
>>>>> or feature?
>>>>
>>>> Did you use it in a loop with __traits(getOverloads) too?
>>>>
>>>> Borrowing from the doc example:
>>> [snip]
>>>
>>> Thanks, the code is easy to fix but my question is in regard to a
>>> potential bug. -- Andrei
>>
>> What is the behavior you would expect?
>
> Error.
>
>> It's somewhat consistent with taking the delegate of an overloaded
>> function.
>
> It was my thinking that in D order of declarations shouldn't ever
> matter. -- Andrei

It makes sense that it should be an error in both cases. But what 
happens to existing code is always the eternal question...

-Steve


More information about the Digitalmars-d mailing list