[Issue 19786] alias to __traits(getMember) wrongfully always binds to this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 4 12:46:08 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19786

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #3 from RazvanN <razvan.nitu1305 at gmail.com> ---
I think that this code should error. Aliases can be made to types or symbols,
however you are trying to alias an expression. For example, simply trying:

alias tmp = rhs.x;

will result in a compilation error. I don't see how that code can be accepted
without redefining the notion of traits. As for the implementation of
TypeTraits, I think it was a mistake to allow all traits to be used as types.
As you can see, some traits cannot be types. This bug report is an example of
how the the type system is bypassed via TypeTraits: the expression returned by
__traits is wrapped in a TypeTraits, therefore the compiler thinks it's okay to
alias it.

--


More information about the Digitalmars-d-bugs mailing list