__traits(compiles , mixin ... )
    Adam D. Ruppe 
    destructionator at gmail.com
       
    Wed Oct 25 20:04:47 UTC 2017
    
    
  
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
    
    
More information about the Digitalmars-d-learn
mailing list