[Issue 3952] pragma(msg,...) has bugs + alternative idea

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 7 00:14:10 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3952



--- Comment #2 from bearophile_hugs at eml.cc 2010-08-07 00:14:07 PDT ---
Andrei has asked if just a pragma(msg) is enough for the error template
constraints.

In some situations it works. But to use pragma(msg) you have to guard it with a
static if. So if the template constraint is a CTFE (that uses a normal 'if'
instead of a 'static if') you can't use it. While ctputs() can be used, this
shows the error message even if it's not required:

bool isGoodFoo(int x) {
    if (x > 10) {
        return true;
    } else {
        pragma(msg, "no good");
        // ctputs("no good");
        return false;
    }
}
void foo(int N)() if (isGoodFoo(N)) {
}
void main() {
    foo!(20)();
}

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


More information about the Digitalmars-d-bugs mailing list