[Issue 18969] New: 'need this for <function>' when passing field or method as template parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 11 13:18:18 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18969
Issue ID: 18969
Summary: 'need this for <function>' when passing field or
method as template parameter
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: simen.kjaras at gmail.com
Consider this code:
class C { int n; }
void fun(alias fn)() {}
unittest {
C c = new C();
fun!(c.n)();
}
Error message:
foo.d(7): Error: need this for fun of type pure nothrow @nogc @safe void()
What's actually needed here is for fun to get a context pointer, either to the
unittest block or to the instance of C.
--
More information about the Digitalmars-d-bugs
mailing list