Thread overview
[Issue 6879] New: The difference of between template matching and IsExp
Nov 02, 2011
Kenji Hara
Nov 02, 2011
Kenji Hara
Nov 02, 2011
Kenji Hara
Nov 02, 2011
Kenji Hara
Nov 15, 2011
Walter Bright
November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6879

           Summary: The difference of between template matching and IsExp
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2011-11-02 04:57:00 PDT ---
I think following code should compile.

----
private template isStaticArray(T : U[N], U, size_t N)
{
    enum bool isStaticArray = true;
}
private template isStaticArray(T)
{
    enum bool isStaticArray = false;
}

void main()
{
    alias int[3] T;

    enum res1 = isStaticArray!T;

    static if (is(T _ : U[N], U, size_t N))
        enum res2 = true;
    else
        enum res2 = false;

    static assert(res1 == res2);   // fails... Why?
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6879



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-11-02 06:00:41 PDT ---
When static if condition is same as follows, the judgement succeeds.

    static if (is(T _ : X, X : U[N], U, size_t N))
        ...

This works as expected, but unneeded two symbols require (_ and X). It seems to me that this syntax has little confusing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6879


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-11-02 07:44:11 PDT ---
I have found the true issue.

alias int[3] T;
static if (is(T _ : U[N], U, int N))      // a: match
static if (is(T _ : U[N], U, uint N))     // b: match
static if (is(T _ : U[N], U, size_t N))   // c: doesn't match

The mismatching of c is 'rejects-valid' issue IMO.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6879


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2011-11-02 09:13:04 PDT ---
https://github.com/D-Programming-Language/dmd/pull/489

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6879


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-11-14 22:45:22 PST ---
https://github.com/D-Programming-Language/dmd/commit/4abf4186980b091b450d0a4e3e2cbba29312c87f

https://github.com/D-Programming-Language/dmd/commit/07910aa6400c797cf67b09f0cd8f9754407e59ea

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