www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bug again?

reply "Zhouxuan" <pycerl qq.com> writes:
mixin template test()
{
	int next;
}

void foo(alias l, alias t)()
{
	t.next = l.next;
}

void main()
{
	struct A
	{
		int next;
	}
	
	A a;

	mixin test l1;
	mixin test l2;
	
	foo!(l1,a);     //ok!
	foo!(l1,l2);    //compilation error!
}
Oct 03 2013
parent "simendsjo" <simendsjo gmail.com> writes:
On Thursday, 3 October 2013 at 12:24:38 UTC, Zhouxuan wrote:
 mixin template test()
 {
 	int next;
 }

 void foo(alias l, alias t)()
 {
 	t.next = l.next;
 }

 void main()
 {
 	struct A
 	{
 		int next;
 	}
 	
 	A a;

 	mixin test l1;
 	mixin test l2;
 	
 	foo!(l1,a);     //ok!
 	foo!(l1,l2);    //compilation error!
 }
Local aliasing problems..? The error message is Error: function D main is a nested function and cannot be accessed from t.foo!(l1, l2).foo Moving the mixins out of main works.
Oct 03 2013