www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11601] New: pragma(msg, ...) output not silenced inside is(typeof()) and __traits(compiles, ...)

https://d.puremagic.com/issues/show_bug.cgi?id=11601

           Summary: pragma(msg, ...) output not silenced inside
                    is(typeof()) and __traits(compiles, ...)
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PST ---
void foo(T)() {
    static if (!is(T : int)) {
        pragma(msg, "Error message.");
    }
    static assert(is(T : int));
}

void main() {
    assert(!is(typeof(foo!string)));
}

The above program outputs "Error message." before concluding that the function
could not be instantiated. In my use case, the pragma is used to tell the user
exactly what he's doing wrong, and have absolutely no use when testing if the
code compiles or not.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 25 2013