Bug 23896 – Contextlessness of local template function not inferred across modules

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-06T08:40:18Z
Last change time
2024-12-13T19:28:39Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
See also
https://issues.dlang.org/show_bug.cgi?id=11385
Moved to GitHub: dmd#20272 →

Comments

Comment #0 by dlang-bugzilla — 2023-05-06T08:40:18Z
/////////// a.d /////////// import b : g; void f() { /*static*/ void fun()() { } g!fun(); } /////////// b.d /////////// auto g(alias fun)() { fun(); } /////////////////////////// We must specify `static` on `fun` explicitly, otherwise the compilation fails: b.d(3): Error: function `b.g!(fun).g` cannot access function `fun` in frame of function `a.f` a.d(5): `fun` declared here a.d(9): Error: template instance `b.g!(fun)` error instantiating It looks like, in `a.d`, the compiler knows that `fun` is static, so it does not instantiate `g` with a context pointer. However, when `g` is compiled, it thinks that it needs a context pointer to call `fun`. One landmark: before 2.065.0, -o- was successful (but -c still failed). The change happened in https://github.com/dlang/dmd/pull/2705.
Comment #1 by robert.schadek — 2024-12-13T19:28:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20272 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB