On Tuesday, 8 March 2016 at 22:35:57 UTC, H. S. Teoh wrote:
On Tue, Mar 08, 2016 at 09:22:35PM +0000, Johan Engelen via
Digitalmars-d 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.
[...]
IMO, this *should* compile and infer T == const(SomeStruct) as
the common type of a and b. But I'm not sure whether or not
this is a regression.
What was surprising to me is that 2.068.2 deduces T = SomeStruct.
But
SomeStruct c = a;
works fine, i.e. copying const(SomeStruct) to a SomeStruct is
fine. Argument passing a struct is just copying, so should be
fine to deduce T=SomeStruct?
( it may help to play a little with the linked code at
dpaste.dzfl.pl )