Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 18, 2005 Static method resolution bug (dmd 0.113) | ||||
---|---|---|---|---|
| ||||
<code> #1 class B{ #2 int f(int i){return i;} #3 static int f(){ #4 return 0; #5 } #6 } #7 class A{ #8 int f(){ #9 return B.f(); #10 } #11 } </code> DMD 0.113 complains: "test.d(9): 'this' is required, but B is not a base class of A" As we can see, class A doesn't have to derive from B to call its static method. BTW, the code compiles if line #2 is commented out. |
February 18, 2005 Re: Static method resolution bug (dmd 0.113) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang | Here is a variant example to demonstrate the bug:
<code>
class B{
void f(int i){}
static void f(){}
}
void main(){
B.f();
}
</code>
DMD error message:
"test.d(6): 'this' is only allowed in non-static member functions"
Interestingly, if we switch the order of method declaration,
the code compiles happily.
<code>
class B{
static void f(){}
void f(int i){}
}
void main(){
B.f();
}
</code>
zwang wrote:
> <code>
> #1 class B{
> #2 int f(int i){return i;}
> #3 static int f(){
> #4 return 0;
> #5 }
> #6 }
> #7 class A{
> #8 int f(){
> #9 return B.f();
> #10 }
> #11 }
> </code>
>
>
> DMD 0.113 complains:
> "test.d(9): 'this' is required, but B is not a base class of A"
> As we can see, class A doesn't have to derive from B to call its
> static method.
> BTW, the code compiles if line #2 is commented out.
|
February 18, 2005 Re: Static method resolution bug (dmd 0.113) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang | zwang wrote: > Here is a variant example to demonstrate the bug: > <code> > class B{ > void f(int i){} > static void f(){} > } > void main(){ > B.f(); > } > </code> > > DMD error message: > "test.d(6): 'this' is only allowed in non-static member functions" <snip top of upside-down reply> This bug has been around for ages and reported several times. Here are just some of the bugs that have been around for a while (if you haven't found it already): http://www.wikiservice.at/wiki4d/wiki.cgi?PendingPeeves Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
February 19, 2005 Re: Static method resolution bug (dmd 0.113) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote:
> This bug has been around for ages and reported several times. Here are just some of the bugs that have been around for a while (if you haven't found it already):
>
> http://www.wikiservice.at/wiki4d/wiki.cgi?PendingPeeves
>
> Stewart.
>
Thanks. I wasn't aware of this page before.
|
Copyright © 1999-2021 by the D Language Foundation