www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Incorrect ParameterIdentifierTuple results?

reply John Chapman <johnch_atms hotmail.com> writes:
ParameterIdentifierTuple produces different results depending on 
whether unnamed parameters are built-in types or user types.

struct SomeType {
   void wrong(SomeType) {}
   void right(int) {}
}

ParameterIdentifierTuple!(__traits(getMember, SomeType, 
"wrong")); // tuple("SomeType")
ParameterIdentifierTuple!(__traits(getMember, SomeType, 
"right")); // tuple("")

Is this the intended behaviour? Shouldn't it just return empty 
strings in both cases? What would be the benefit of returning 
user type names?
Nov 30 2018
parent reply Neia Neutuladh <neia ikeran.org> writes:
On Fri, 30 Nov 2018 18:18:36 +0000, John Chapman wrote:
 ParameterIdentifierTuple!(__traits(getMember, SomeType, "wrong"));
 // tuple("SomeType")
 ParameterIdentifierTuple!(__traits(getMember, SomeType, "right"));
 // tuple("")
Compiler and version would be helpful here. I'm on DMD 2.081.1 and it yields the same results in each case: _param_0
Nov 30 2018
parent reply John Chapman <johnch_atms hotmail.com> writes:
On Friday, 30 November 2018 at 19:07:14 UTC, Neia Neutuladh wrote:
 Compiler and version would be helpful here.

 I'm on DMD 2.081.1 and it yields the same results in each case: 
 _param_0
Hmm, I was calling ParameterIdentifierTuple inside a lambda - once I moved it into my main function I got the same output as you. But … change SomeType to an interface and it reproduces the issue I reported above. interface SomeType { void wrong(SomeType); void right(int); } I'm on DMD 2.083.0.
Nov 30 2018
parent John Chapman <johnch_atms hotmail.com> writes:
On Friday, 30 November 2018 at 19:37:52 UTC, John Chapman wrote:
 On Friday, 30 November 2018 at 19:07:14 UTC, Neia Neutuladh 
 wrote:
 Compiler and version would be helpful here.

 I'm on DMD 2.081.1 and it yields the same results in each 
 case: _param_0
Hmm, I was calling ParameterIdentifierTuple inside a lambda - once I moved it into my main function I got the same output as you. But … change SomeType to an interface and it reproduces the issue I reported above. interface SomeType { void wrong(SomeType); void right(int); } I'm on DMD 2.083.0.
On Friday, 30 November 2018 at 19:37:52 UTC, John Chapman wrote: This is pretty broken so I've opened a bug: https://issues.dlang.org/show_bug.cgi?id=19456
Nov 30 2018