[Issue 22903] New: IFTI for immediately-invoked lambda keeps qualifier for pointer/slice argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 18 20:33:26 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22903
Issue ID: 22903
Summary: IFTI for immediately-invoked lambda keeps qualifier
for pointer/slice argument
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list