[Issue 18289] static function and access frame
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 13 16:27:08 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=18289
--- Comment #1 from Aurelien Fredouelle <aurelien.fredouelle+dlang at gmail.com> ---
Ran into the same issue, here is some extra sample code to better understand
the problem:
template A(alias fun)
{
void A() {
fun();
}
}
struct B(alias fun)
{
static void opCall() {
fun();
}
}
void foo() {}
void main() {
static void bar() {}
void hun() {}
A!foo(); // OK
B!foo(); // OK
A!bar(); // OK
B!bar(); // OK
A!hun(); // OK
B!hun(); // ERROR! static function app.main.B!(hun).B.opCall cannot access
frame of function D main
}
The issue happens when instantiating the templated struct with an object that
lives on the stack of the calling function (such as the `hun` function). But it
looks like this case is not so different from the previous one (`A!hun()`),
using an eponymous function template rather than a struct with a static opCall.
Is it really expected for one case to succeed and the other to fail?
--
More information about the Digitalmars-d-bugs
mailing list