www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15320] New: static assert(__traits(compiles, xys)) considered

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

          Issue ID: 15320
           Summary: static assert(__traits(compiles, xys)) considered
                    harmful
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

The pattern `static assert(__traits(compiles, xyz))` arised probably as a
converse to its negation, e.g.:

static assert( __traits(compiles, emplace(&ss2)));
static assert(!__traits(compiles, emplace(&ss2, SS2.init)));

However, the pattern should be avoided for two reasons:

1. Often it's best to also execute the code and make sure it works as expected

2. When working on the module, a failure of `static assert(__compiles)` does
not show the reason in the error messages. This makes code more difficult to
work with gratuitously.

We should eliminate this pattern from all of Phobos.

--
Nov 11 2015