Comment #0 by snarwin+bugzilla — 2022-03-18T20:33:26Z
As of DMD 2.099.0, the following program fails to compile:
---
const(int*) p;
static assert(is(typeof((x => x)(p)) == const(int)*));
---
The error message is:
---
onlineapp.d(2): Error: static assert: `is(const(int*) == const(int)*)` is false
---
According to the language spec for IFTI [1], "the deduced type for dynamic array and pointer arguments has an unqualified head", so the type deduced for `x` should be `const(int)*`, not `const(int*)`.
If the lambda is defined in a separate statement, the correct type is deduced:
---
const(int*) p;
alias id = x => x;
static assert(is(typeof(id(p)) == const(int)*)); // passes
---
[1]: https://dlang.org/spec/template.html#ifti
Comment #1 by timon.gehr — 2024-05-31T06:57:52Z
There is no IFTI taking place in in the first example. The type of the delegate is inferred from context.
Comment #2 by robert.schadek — 2024-12-13T19:21:34Z