__traits(compiles) is true with warnings as errors

Dennis dkorpel at gmail.com
Fri Oct 15 14:59:47 UTC 2021

On Thursday, 14 October 2021 at 11:08:24 UTC, bauss wrote:
> What could be useful is a new trait (to not break existing 
> code) like __traits(warning, ...) which does the same as 
> __traits(compiles) but also checks whether the arguments would 
> cause a warning by the compiler.

Noooo! Warnings suck. Errors are fine, nothing is fine, a big bag 
of unspecified 'maybes' that are put on either side depending on 
the user is not.

Unfortunately, dub makes warnings into errors by default, but you 
can use `buildRequirements "silenceWarnings"` or 
`buildRequirements "allowWarnings"` to mitigate it.

If implicit float truncation is really error prone, it should be 
deprecated. Otherwise the compiler should shut up about it.

More information about the Digitalmars-d-learn mailing list