[Issue 17701] DMD does not properly gag errors when passing `typeof` to a template inside __traits(compiles)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 28 18:02:14 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17701

Chris Wright <dhasenan at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dhasenan at gmail.com

--- Comment #1 from Chris Wright <dhasenan at gmail.com> ---
`typeof` is a keyword with specific syntax. In order for the compiler to get to
the point where it runs `__traits(complies, ...)`, it has to successfully parse
your code. If you violate syntax rules, as in your example, it can't
successfully parse your code.

This is similar to the rule that code inside inactive `version` blocks must be
parseable.

In order to handle cases like this, you can use string mixins:

    static assert(!__traits(compiles, {mixin(q{alias justTypes = ...;});}));

--


More information about the Digitalmars-d-bugs mailing list