www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2725] New: Pattern matching in static if not working with variadic arguments

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

           Summary: Pattern matching in static if not working with variadic
                    arguments
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


struct A(B...) {}

void main()
{
    alias A!(int, float) X;
    static if (!is(X Y == A!(Z), Z))
    {
        static assert(false);
    }
}

This example fails the static assert. If one removes the float in the
instantiation of A the example compiles.

The compiler should match Z to the type tuple (int, float). Otherwise it is
impossible to detect whether a type is an instantiation of a variadic template.


-- 
Mar 10 2009
next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2725





------- Comment #1 from bugzilla digitalmars.com  2009-03-13 16:40 -------
The is expression needs to be written as:

    static if (!is(X Y == A!(Z), Z...))

with the addition of the ... to indicate that Z is a tuple parameter. It still
won't compile right, though, so I'll fix it.


-- 
Mar 13 2009
parent Derek Parnell <derek psych.ward> writes:
On Fri, 13 Mar 2009 21:40:29 +0000 (UTC), d-bugmail puremagic.com wrote:

 static if (!is(X Y == A!(Z), Z...))

BTW, this is the sort of thing that my "ASCII version of APL" was referring to. There is no 'intuitive' way to make any sense of that code phrase. I can't even workout how to say it out loud, as in translate it into English. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Mar 13 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2725


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2009-04-01 13:54 -------
Fixed DMD 2.027


-- 
Apr 01 2009