Bug 22903 – IFTI for immediately-invoked lambda keeps qualifier for pointer/slice argument

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-18T20:33:26Z
Last change time
2024-12-13T19:21:34Z
Assigned to
No Owner
Creator
Paul Backus
Moved to GitHub: dmd#18091 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18091 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB