[Issue 15781] New: Type deduction const
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Mar 9 02:36:47 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15781
Issue ID: 15781
Summary: Type deduction const
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: jbc.engelen at gmail.com
```
struct TypeA {
int value;
}
auto foo(T)(T start, T end) {
import std.stdio;
writeln(typeid(T));
}
void main() {
alias Tiep = TypeA;
const Tiep a;
Tiep b;
Tiep c = a; // This is fine
foo(c,b);
foo(a,b); // This is not fine with DMD 2.069.2
}
```
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).
For `alias Tiep = int;` it compiles with DMD 2.070.2.
Also when modifying the code to read `auto foo(T)(const T start, const T end)`.
This issue was reported after a brief forum discussion:
http://forum.dlang.org/thread/pviqlkktqzeusjualhuk@forum.dlang.org.
--
More information about the Digitalmars-d-bugs
mailing list