[Issue 24788] New: Template inferrence bug?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 2 23:40:27 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24788
Issue ID: 24788
Summary: Template inferrence bug?
Product: D
Version: D2
Hardware: All
URL: http://dlang.org/
OS: All
Status: NEW
Severity: normal
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
void f(T)(const(T)[] x, const(T)* y) {}
void test()
{
// this works; T is inferred as int
int[] x;
const int y;
f(x, &y);
// fails: expected that T is inferred as int*
int*[] a;
const int* b;
f(a, &b);
}
Something about a/b being an arrangement of int* compared to x/y with int
causes this to fail.
I reckon the non-uniformity of this type deduction logic is a bug.
This non-uniformity has caused me several problems with meta code.
I think it's banging into an issue with const promotion; if you remove const
from y and b, both cases work properly.
--
More information about the Digitalmars-d-bugs
mailing list