Thread overview
Mixin bug: argument types
May 29, 2004
Hauke Duden
May 29, 2004
J Anderson
May 29, 2004
Hauke Duden
May 29, 2004
The following code does not compile (neither with DMD 0.90 nor with 0.91).


template FooDefaults()
{
	void foo(int i)
	{
		return foo(i,0);
	}	
}


class Foo
{
	mixin FooDefaults;
	
	void foo(int i,int j)
	{
	}
}


The error message is:

mixinbug.d(5): function foo (int i) does not match argument types (int,int)
mixinbug.d(5): Error: expected 1 arguments, not 2


I believe this is a compiler bug.



Hauke
May 29, 2004
Hauke Duden wrote:

> The following code does not compile (neither with DMD 0.90 nor with 0.91).
>
>
> template FooDefaults()
> {
>     void foo(int i)
>     {
>         return foo(i,0);
>     }   }
>
>
> class Foo
> {
>     mixin FooDefaults;
>         void foo(int i,int j)
>     {
>     }
> }
>
>
> The error message is:
>
> mixinbug.d(5): function foo (int i) does not match argument types (int,int)
> mixinbug.d(5): Error: expected 1 arguments, not 2
>
>
> I believe this is a compiler bug.
>
>
>
> Hauke


You need to tell it which foo.  This is using the same rules as import.

template FooDefaults()
{
   void foo(int i)
   {
       return this.foo(i,0);
   }   }

class Foo
{
   mixin FooDefaults;
      void foo(int i,int j)
   {
   }
}

-- 
-Anderson: http://badmama.com.au/~anderson/
May 29, 2004
Thanks, this helped (somewhat). I still have problems getting this to work in my realworld code, but I suspect it is really an issue with the language design, so I'll post about it to the D.d group.

J Anderson wrote:
> Hauke Duden wrote:
> 
>> The following code does not compile (neither with DMD 0.90 nor with 0.91).
>>
>>
>> template FooDefaults()
>> {
>>     void foo(int i)
>>     {
>>         return foo(i,0);
>>     }   }
>>
>>
>> class Foo
>> {
>>     mixin FooDefaults;
>>         void foo(int i,int j)
>>     {
>>     }
>> }
>>
>>
>> The error message is:
>>
>> mixinbug.d(5): function foo (int i) does not match argument types (int,int)
>> mixinbug.d(5): Error: expected 1 arguments, not 2
>>
>>
>> I believe this is a compiler bug.
>>
>>
>>
>> Hauke
> 
> 
> 
> You need to tell it which foo.  This is using the same rules as import.
> 
> template FooDefaults()
> {
>    void foo(int i)
>    {
>        return this.foo(i,0);
>    }   }
> 
> class Foo
> {
>    mixin FooDefaults;
>       void foo(int i,int j)
>    {
>    }
> }
>