bug in compiles?
Jacob Carlborg
doob at me.com
Fri Apr 12 09:43:01 UTC 2019
On 2019-04-11 20:13, Alex wrote:
> The following code works when I comment out the static if
>
> //static if (__traits(compiles, __traits(getAttributes, T)))
> static foreach(a; __traits(getAttributes, T)) Attributes ~=
>
>
> There seems to be absolutely no reason why this code would fail with the
> static if but pass without it but in the first case I get no attributes
> because the __traits compiles fails.
>
>
>
> __traits(compiles, __traits(getAttributes, T))
>
> vs
>
> __traits(getAttributes, T)
>
> How could it not compile in the first case and yet work in the foreach?
The problem is that "__traits(getAttributes, T)" in it self is not valid
code. It needs to be part of larger expression or statement. The
following seems to work:
https://run.dlang.io/is/JWkdbQ
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list