June 11, 2018 [Issue 18969] New: 'need this for <function>' when passing field or method as template parameter | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: simen.kjaras@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. -- |
Copyright © 1999-2021 by the D Language Foundation