Thread overview
[Issue 6322] New: IFTI doesn't support static arrays
Jul 15, 2011
Denis
Jul 15, 2011
yebblies
Jul 15, 2011
Denis
Apr 09, 2013
Kenji Hara
July 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6322

           Summary: IFTI doesn't support static arrays
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: verylonglogin.reg@gmail.com


--- Comment #0 from Denis <verylonglogin.reg@gmail.com> 2011-07-15 07:25:46 PDT ---
Maybe it duplicates some other issue, but I didn't find it. Or maybe it is issue 2296.

void f(T: T[n], size_t n)(T[n] t) { }

void main()
{
    int[2] a;
    f!(typeof(a))(a); //this compiles
    f(a); //this doesn't
}

main.d(7): Error: template main.f(T : T[n],uint n) does not match any function
template declaration
main.d(7): Error: template main.f(T : T[n],uint n) cannot deduce template
function from argument types !()(int[2u])

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


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |yebblies@gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-07-16 00:32:16 EST ---
void f(T: U[n], U, size_t n)(T t) { } works as a substitute.

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



--- Comment #2 from Denis <verylonglogin.reg@gmail.com> 2011-07-15 07:47:46 PDT ---
Another workaround is D2 constraints (more powerful and less buggly):

import std.traits;
void f(Tn)(Tn t) if(isStaticArray!Tn) { }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6322


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

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


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-08 21:11:37 PDT ---
(In reply to comment #0)
> void f(T: T[n], size_t n)(T[n] t) { }
> 
> void main()
> {
>     int[2] a;
>     f!(typeof(a))(a); //this compiles
>     f(a); //this doesn't
> }

The template function never called with IFTI, because:
1. T is deduced to int from the argument 'a'.
2. T is tested with specialized signature `: T[n]`. But T is int, so never
match.

Although it looks weird behavior, it is not a bug.

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