[Issue 693] New: 'this' can't be used as an alias parameter for a mixin
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 16 21:26:35 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=693
Summary: 'this' can't be used as an alias parameter for a mixin
Product: D
Version: 0.177
Platform: All
OS/Version: All
Status: NEW
Severity: minor
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
This may not be a bug for some technical reason unbeknownst to me that the spec
mentions (if so downgrade it to enhancement please), but I found it unexpected.
You can't use 'this' as an alias paramter to a mixin in a class member
function. The workaround is pretty easy, you just assign it to a local dummy
variable, and use that instead.
import std.stdio : writefln;
template printer_mix(alias T)
{
void print() {
writefln(T);
}
}
class Foo
{
void dump() {
// Error: mixin printer_mix!(this) does not match any template
declaration
mixin printer_mix!(this);
// this version ok:
//Foo x = this;
//mixin printer_mix!(x);
print();
}
char[] toString() { return "I'm Batman"; }
}
void main()
{
Foo f = new Foo();
f.dump();
}
--
More information about the Digitalmars-d-bugs
mailing list