Bug 19456 – ParameterIdentifierTuple incorrect for abstract methods with unnamed parameters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-11-30T22:42:07Z
Last change time
2018-12-09T12:05:18Z
Assigned to
No Owner
Creator
John Chapman
Comments
Comment #0 by johnch_atms — 2018-11-30T22:42:07Z
ParameterIdentifierTuple returns incorrect results for abstract methods on classes and interfaces.
class SomeClass {
abstract void first(SomeClass);
abstract void second(int);
void third(SomeClass) {}
}
pragma(msg, ParameterIdentifierTuple!(__traits(getMember, SomeClass, "first")); // outputs: tuple("SomeClass")
pragma(msg, ParameterIdentifierTuple!(__traits(getMember, SomeClass, "second")); // outputs: tuple("")
pragma(msg, ParameterIdentifierTuple!(__traits(getMember, SomeClass, "third")); // outputs: tuple("_param_0")
ParameterIdentifierTuple uses __traits(identifier,...) under the hood, and it looks like that's ultimately where the issue is. ParameterIdentifierTuple on non-abstract methods always seems to produce "_param_0", "_param_1" and so on. However, I'd expect to see a tuple of empty strings in all three cases.
Comment #1 by simen.kjaras — 2018-12-03T09:52:39Z
Short of filtering out parameters that start with '_param_', there seems to be no way to guess if the third case has specified parameter names.
PR fixing the first part:
https://github.com/dlang/phobos/pull/6789
Comment #2 by github-bugzilla — 2018-12-09T12:05:18Z