www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11195] New: Error messages not suppressed in __traits(compiles,...)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11195

           Summary: Error messages not suppressed in
                    __traits(compiles,...)
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PDT ---
import std.traits : ParameterTypeTuple;

void foo()() {}

void main() {
    assert(!__traits(compiles, {struct A{ParameterTypeTuple!foo tmp;}}));
}

The above program fails to compile with this message:
bug.d(6): Error: template instance ParameterTypeTuple!(foo) does not match
template declaration ParameterTypeTuple(func...) if (func.length == 1 &&
isCallable!func)

Replace ParameterTypeTuple!foo with a simple type, and things work wonderfully.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11195


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



05:44:10 PDT ---
Same issue with is(typeof()) as well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11195


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Error messages not          |Error messages not
                   |suppressed in               |suppressed in
                   |__traits(compiles,...)      |__traits(compiles,...) for
                   |                            |template instantiation
                   |                            |nested in aggregate



PDT ---
True, I forgot mentioning that. Simplified example:

template bar(T...) {
    alias bar = void;
}

void foo()() {}

void main() {
    assert(!__traits(compiles, {struct A{bar!foo tmp;}}));
    assert(!is(typeof({struct A{bar!foo tmp;}})));
}

Also worth noting that these work (note the lack of a surrounding struct):

    assert(!__traits(compiles, {bar!foo tmp;}));
    assert(!is(typeof({bar!foo tmp;})));

I updated the summary to reflect this.

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