www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2025] New: Inconsistent rules for instantiating templates with a tuple parameter

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

           Summary: Inconsistent rules for instantiating templates with a
                    tuple parameter
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


The template with non-tuple parameter is preferred if that parameter is a value
(Case 1). The template with tuple parameter is preferred if the non-tuple
parameter is a type (Case 2).

Case 1
----
template Foo(int i)
{
    pragma(msg, "One");
}

template Foo(A...)
{
    pragma(msg, "Many");
}

alias Foo!(1) foo;
----
Outputs: One

Case 2
----
template Foo(T)
{
    pragma(msg, "One");
}

template Foo(A...)
{
    pragma(msg, "Many");
}

alias Foo!(int) foo;
----
Outputs: Many

Probably both cases should result in an ambiguity error.


-- 
Apr 22 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2025


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |spec




------- Comment #1 from smjg iname.com  2008-11-21 20:55 -------
This is either wrong-code or accepts-invalid, but we need a clarification in
the spec first.

Compiler behaviour is most certainly wrong in case 2 - it leaves no way to
instantiate the Foo(T) version.


-- 
Nov 21 2008