Type inference of a function parameter

Adel Mamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 29 13:20:45 PDT 2015


Hello,

Why dmd cannot inference the type of 'arr' in my_func() parameter?
test.d:

import std.stdio;

void my_func(auto arr)
{
   writeln(arr);
}

void main()
{
   auto arr = new int[5];

   arr = [1, 2, 3, 4, 5];

   my_func(arr);
}

> dmd test.d
test.d(3): Error: undefined identifier arr

Adel


More information about the Digitalmars-d-learn mailing list