Thread overview | |||||
---|---|---|---|---|---|
|
August 07, 2010 itfi limitation or bug on my part? | ||||
---|---|---|---|---|
| ||||
module test; void main() { int[] foos; func1(foos); } void func1(T)(const T[] foos) { T afoo; func2(foos, afoo); } void func2(T)(const T[] foos, out T afoo) { } $ dmd -c test.d test.d(12): Error: template test.func2(T) does not match any function template declaration test.d(12): Error: template test.func2(T) cannot deduce template function from argument types !()(const(int[]),int) test.d(6): Error: template instance test.func1!(int) error instantiating Ignore style.. this is a massively reduced case from a much more complex block of code. |
August 07, 2010 Re: itfi limitation or bug on my part? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Roberts | Brad Roberts wrote:
> module test;
>
> void main()
> {
> int[] foos;
> func1(foos);
> }
>
> void func1(T)(const T[] foos)
> {
> T afoo;
> func2(foos, afoo);
> }
>
> void func2(T)(const T[] foos, out T afoo)
> {
> }
>
> $ dmd -c test.d
> test.d(12): Error: template test.func2(T) does not match any function template
> declaration
> test.d(12): Error: template test.func2(T) cannot deduce template function from
> argument types !()(const(int[]),int)
> test.d(6): Error: template instance test.func1!(int) error instantiating
>
> Ignore style.. this is a massively reduced case from a much more complex block
> of code.
>
Looks like a compiler bug. If you change func2 to this:
void func2(T, U)(const T[] foos, out U afoo)
{
static assert(is(T==U));
}
test0.d(212): Error: static assert (is(const(int) == int)) is false
test0.d(207): instantiated from here: func2!(const(int),int)
test0.d(201): instantiated from here: func1!(int)
T should be "const(int)" instead of "int".
|
August 07, 2010 Re: itfi limitation or bug on my part? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | On 8/7/2010 12:42 PM, Don wrote:
> Brad Roberts wrote:
>> module test;
>>
>> void main()
>> {
>> int[] foos;
>> func1(foos);
>> }
>>
>> void func1(T)(const T[] foos)
>> {
>> T afoo;
>> func2(foos, afoo);
>> }
>>
>> void func2(T)(const T[] foos, out T afoo)
>> {
>> }
>>
>> $ dmd -c test.d
>> test.d(12): Error: template test.func2(T) does not match any function template
>> declaration
>> test.d(12): Error: template test.func2(T) cannot deduce template function from
>> argument types !()(const(int[]),int)
>> test.d(6): Error: template instance test.func1!(int) error instantiating
>>
>> Ignore style.. this is a massively reduced case from a much more complex block of code.
>>
>
> Looks like a compiler bug. If you change func2 to this:
>
> void func2(T, U)(const T[] foos, out U afoo)
> {
> static assert(is(T==U));
> }
>
> test0.d(212): Error: static assert (is(const(int) == int)) is false
> test0.d(207): instantiated from here: func2!(const(int),int)
> test0.d(201): instantiated from here: func1!(int)
>
> T should be "const(int)" instead of "int".
Other way around.. T should be 'int' instead of 'const(int)'. Thanks for the confirmation. I thought the same thing but wanted independent confirmation. I'll file the bug.
|
Copyright © 1999-2021 by the D Language Foundation