https://issues.dlang.org/show_bug.cgi?id=15781
Kenji Hara <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Summary|Template type deduction |[REG2.069] Template type |failure with same-type |deduction failure with |variables with different |same-type variables with |constness |different constness --- Comment #2 from Kenji Hara <[email protected]> --- (In reply to Johan Engelen from comment #0) > The code compiles fine with DMD 2.068.2. > The code fails to compile with DMD 2.068.2 and DMD 2.070.2: > deduce.d(19): Error: template deduce.foo cannot deduce function from > argument types !()(const(TypeA), TypeA), candidates are: > deduce.d(5): deduce.foo(T)(T start, T end) > > I believe this is a regression. > DMD 2.068.2 deduces T = TypeA (non-const). This is a rejects-valid issue from 2.069, so is a regression. But, the behavior in 2.068 -- T is deduced to TypeA (non-const) -- is not intentional result, because there was order-dependent bug. struct S { int value; } void foo(T)(T a, T b) { pragma(msg, T); } void main() { const S cs; S ms; foo(cs, ms); // prints 'S' foo(ms, cs); // prints 'const(S)', inconsistent! } Therefore, from the built-in common type calculation mechanism, the T should be deduced to const(S) independent from the order of function arguments. --
