Feature request: __traits(canInstantiate), like __traits(compiles) but without suppressing syntax errors

MWumpusZ sinkhole01 at bregalad.de
Thu Jan 16 08:28:44 UTC 2020

On Wednesday, 15 January 2020 at 15:13:08 UTC, FeepingCreature 
> Right now it's impossible to check "is there a valid (template) 
> specialization for this function call" without also saying "and 
> by the way, if there's a syntax error in the function, suppress 
> the error and return false."

Another example:

The case which bothered me, and which I nagged FeepingCreature 
about leading to the post above, is that he has written us code 
to automatically JSON-decode to simple D structs, and we can 
override that automatic decoding where necessary, by writing a

T decode(T: SomeSpecialStruct)(const JSONValue value)

This works very well.... BUT: If I make an error such that my 
decode does not even compile, then I get no indication of this - 
a decoder is automatically generated instead, and at runtime I 
get strange behavior because the "wrong" decoder is being used.  
Ideally I get decode errors, but it is easy to imagine cases 
where that would not even occur.

More information about the Digitalmars-d mailing list