On Wednesday, 25 October 2017 at 20:04:47 UTC, Adam D. Ruppe wrote:
On Wednesday, 25 October 2017 at 19:50:31 UTC, SrMordred wrote:
so why this line resolves to false?

Because it is illegal to put a statement or declaration inside __traits(compiles). sorry, I should have said that before... even though the mixin can be legal in another context, it won't be in the __traits context due to this:

https://dlang.org/spec/traits.html#compiles

"Returns a bool true if all of the arguments compile (are semantically correct). The arguments can be symbols, types, or expressions that are syntactically correct. The arguments cannot be statements or declarations. "


When there's a closing ;, it is a mixin statement.

void F(){}
pragma(msg, __traits( compiles, mixin("F();") ) );//false

Oh, now thats explains. I thought that a "mixin statement" was equal to the argument type that it compiles to. Thanks!

Reply via email to