[Issue 8441] mixin containing template functions causes compiler errors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 18 06:07:41 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8441
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #2 from monarchdodra at gmail.com 2013-01-18 06:07:40 PST ---
It would appear the problem lies between a combination of mixin identifier, and
template overload:
Here is a reduced test case:
//----
mixin template T() {
void k()(){}
void j()(){}
void j(int i)(){}
}
class X
{
mixin T t0;
}
void main (){
X x;
x.k!()(); //Fine
x.j!()(); //Fine
x.t0.k!()(); //Fine
x.t0.j!()(); //Derp
}
//----
main.d(12): Error: function expected before (), not 'x.j!()'
//-----
(In reply to comment #1)
> Can also reproduced with:
> https://github.com/eskimor/phobos/blob/new_signal/std/signals.d
>
> And is currently a blocker for a full signals2 implementation.
I don't know how you are affected by this, but you can workaround the problem
by avoiding the template overload ambiguity. For example, this seems to work:
//----
mixin template T(string i) {
private {
auto j1(string s="a", U)(U u1, U u2) {
return j!(s, U)(u1, u2);
}
auto j2(int i,string s="a", W)(W u1, W u2) {
return j!(i, s, W)(u1, u2);
}
}
auto j(string s="a", U)(U u1, U u2) {
return 0;
}
auto j(int i,string s="a", W)(W u1, W u2) {
return i;
}
mixin("
class F" ~ i ~ " {
auto j(string s=\"a\", U)(U u1, U u2) {
return this.outer.t" ~ i ~ ".j1!(s,U)(u1,u2);
}
auto j(int i,string s=\"a\", W)(W u1, W u2) {
return this.outer.t" ~ i ~ ".j2!(i,s,W)(u1,u2);
}
}
auto f"~i~"() {
return new F"~i~"();
}
");
}
class X {
mixin T!("1") t0;
alias t0 t1;
}
void main (){
X x = new X();
x.f1().j!(3,"a")(2.2, 3.3);
}
//----
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list