digitalmars.D.bugs - [Issue 22903] New: IFTI for immediately-invoked lambda keeps
- d-bugmail puremagic.com (35/35) Mar 18 2022 https://issues.dlang.org/show_bug.cgi?id=22903
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 puremagic.com Reporter: snarwin+bugzilla 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 --
Mar 18 2022