www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [UDA] Error: first argument is not a symbol

reply drug <drug2004 bk.ru> writes:
https://dpaste.dzfl.pl/9548c481ce46

shouldn't commented line return 'false' as built-in type 'int' has no 
any UDAs instead of cryptic (for me) message about wrong first argument?
Sep 15 2016
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 9/15/16 4:48 AM, drug wrote:
 https://dpaste.dzfl.pl/9548c481ce46

 shouldn't commented line return 'false' as built-in type 'int' has no
 any UDAs instead of cryptic (for me) message about wrong first argument?
This is due to int not being a symbol, which apparently __traits(getAttributes, ...) requires. int is a keyword and not considered a symbol. An annoying distinction without a difference in this case. I'd say it's something we should fix, but this kind of problem has existed forever. Not sure if it will get attention. -Steve
Sep 15 2016
next sibling parent drug <drug2004 bk.ru> writes:
15.09.2016 15:56, Steven Schveighoffer пишет:
 This is due to int not being a symbol, which apparently
 __traits(getAttributes, ...) requires.

 int is a keyword and not considered a symbol. An annoying distinction
 without a difference in this case. I'd say it's something we should fix,
 but this kind of problem has existed forever. Not sure if it will get
 attention.

 -Steve
Thank you for answer
Sep 15 2016
prev sibling parent Jonathan M Davis via Digitalmars-d-learn writes:
On Thursday, September 15, 2016 08:56:18 Steven Schveighoffer via Digitalmars-
d-learn wrote:
 On 9/15/16 4:48 AM, drug wrote:
 https://dpaste.dzfl.pl/9548c481ce46

 shouldn't commented line return 'false' as built-in type 'int' has no
 any UDAs instead of cryptic (for me) message about wrong first argument?
This is due to int not being a symbol, which apparently __traits(getAttributes, ...) requires. int is a keyword and not considered a symbol. An annoying distinction without a difference in this case. I'd say it's something we should fix, but this kind of problem has existed forever. Not sure if it will get attention.
Given the fact that Walter theoretically agreed to fix it so that alias parameters accepted built-in types and not just symbols, that might translate to treating int and friends as symbols in general, which would fix this case. I don't know. There's certainly no need to ever check whether a built-in type has a UDA, because it never will, so in that respect, it doesn't really matter, but it could become annoying in generic code, because you might have to explicitly check for built-in symbols to workaround this. I've opened an enhancement request: https://issues.dlang.org/show_bug.cgi?id=16496 - Jonathan M Davis
Sep 15 2016