Thread overview
[Issue 6891] New: template with uint value parameter causes several issues
Nov 04, 2011
Matt Peterson
May 01, 2012
SomeDude
May 02, 2012
Kenji Hara
May 02, 2012
Walter Bright
November 04, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6891

           Summary: template with uint value parameter causes several
                    issues
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: revcompgeek@gmail.com


--- Comment #0 from Matt Peterson <revcompgeek@gmail.com> 2011-11-04 16:31:32 PDT ---
This bug is closely related to issue 4960 and issue 6745, although I don't think it's an exact duplicate.

One of the simplest test cases I could come up with:
----
struct S(uint N) {
    void f(S!N u) { }
}

alias S!1 A;

void main()
{
    A().f(A());
}
----

Which gives the following error messages:
templatetest.d(10): Error: function templatetest.S!(1).S.f (S!(N) u) is not
callable using argument types (S!(1))
templatetest.d(10): Error: cannot implicitly convert expression (S()) of type
S!(1) to S!(N)

In this form it is fairly easy to work around, by either changing uint to int in the struct declaration or using S!1u instead of S!1. However, I derived this from a slightly different test case:
----
struct S(int N, T) {
    void f(U)(S!(N, U) u) { }
}

alias S!(1, void) A;

void main()
{
    A().f(A());
}
----

Which gives me these error messages:
templatetest.d(10): Error: template templatetest.S!(1,void).S.f(U) does not
match any function template declaration
templatetest.d(10): Error: template templatetest.S!(1,void).S.f(U) cannot
deduce template function from argument types !()(S!(1,void))

In this version, changing the type of N or 1 doesn't do anything, and I have not found a way to work around it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6891


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-05-01 15:51:12 PDT ---
The first case compiles with 2.059, not the second.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
           Platform|x86_64                      |All
         OS/Version|Linux                       |All


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-01 23:12:33 PDT ---
First case may be a dup of bug 3467.

I've posted a pull request for the second case: https://github.com/D-Programming-Language/dmd/pull/919

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



--- Comment #3 from github-bugzilla@puremagic.com 2012-05-02 14:35:17 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/48a8e64bd0181a847098cf7de2baf4945ff6ecac fix Issue 6891 - template with uint value parameter causes several issues

https://github.com/D-Programming-Language/dmd/commit/6dd100055be1fe13d3594213a72a04c7ecff44b2 Merge pull request #919 from 9rnsr/fix6891

Issue 6891 - template with uint value parameter causes several issues

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


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