Deduction regression or improvement?

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 8 17:27:41 PST 2016


On 03/08/2016 11:22 PM, Johan Engelen wrote:
> Hi all,
>   Should the following compile or not?
> 
> auto foo(T)(T start, T end) {}
> void main() {
>     const SomeStruct a;
>     SomeStruct b;
>     foo(a,b);
> }
> See http://dpaste.dzfl.pl/15581af64747
> 
> DMD 2.068.2 compiles and does not complain.
> DMD 2.069.2 gives deduction error: "cannot deduce function from argument
> types !()(const(SomeStruct), SomeStruct),   candidates are:  foo(T)(T
> start, T end)"
> 
> Is this a regression or intended?  I did not find something about it in
> the release notes.
> 
> Thanks,
>   Johan
> 
> 
> 

Looks like regression to me.

If SomeStruct contains indirections, it should be able to deduce T as
const(SomeStruct).

It SomeStruct is strict value type, deducing T as both SomeStruct and
const(SomeStruct) would be fine.



More information about the Digitalmars-d mailing list