| Thread overview | |||||
|---|---|---|---|---|---|
| 
 | 
| May 29, 2004Mixin bug: argument types | ||||
|---|---|---|---|---|
| 
 | ||||
| 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, 2004Re: Mixin bug: argument types | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Hauke Duden | 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, 2004Re: Mixin bug: argument types | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to J Anderson | 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)
>    {
>    }
> }
> 
 | |||
Copyright © 1999-2021 by the D Language Foundation
  Permalink
Permalink Reply
Reply