Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 21, 2004 static overloaded method with parent overload | ||||
---|---|---|---|---|
| ||||
Class access to static overloaded method do not works. <code> class A { static void bar(int x) {} } class B: A { alias A.bar bar; static void bar(char[] x) {} } void main() { B b = new B(); b.bar(1); // ok b.bar("1"); // ok B.bar(1); // error: function expected before (), not 'bar' B.bar("1"); // error: function expected before (), not 'bar' } </code> Mixins have that bug too. |
July 17, 2004 Re: static overloaded method with parent overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sark7 | DMD 0.95 still have this bug:
<code>
template TA()
{
static void foo(int i) { }
}
struct B
{
mixin TA!() ta;
alias ta.foo foo;
static void foo(int i, int j) { }
}
void main()
{
B.foo(1); // error: function expected before (), not 'foo'
}
</code>
> Class access to static overloaded method do not works.
>
> <code>
> class A
> {
> static void bar(int x) {}
> }
>
> class B: A
> {
> alias A.bar bar;
> static void bar(char[] x) {}
> }
>
> void main()
> {
> B b = new B();
> b.bar(1); // ok
> b.bar("1"); // ok
>
> B.bar(1); // error: function expected before (), not 'bar'
> B.bar("1"); // error: function expected before (), not 'bar'
> }
> </code>
>
> Mixins have that bug too.
|
July 17, 2004 Re: static overloaded method with parent overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Zaitseff | Ilya Zaitseff wrote: > DMD 0.95 still have this bug: > > <code> > template TA() > { > static void foo(int i) { } > } > > struct B > { > mixin TA!() ta; > alias ta.foo foo; > static void foo(int i, int j) { } > } > > void main() > { > B.foo(1); // error: function expected before (), not 'foo' > } > </code> I'm learning here so maybe I've got this all wrong, but isn't one supposed to instantiate a struct prior to accessing it's members? shouldn't your main read this instead? void main() { B b; b.foo(1); } Just a thought! >> Class access to static overloaded method do not works. >> >> <code> >> class A >> { >> static void bar(int x) {} >> } >> >> class B: A >> { >> alias A.bar bar; >> static void bar(char[] x) {} >> } >> >> void main() >> { >> B b = new B(); >> b.bar(1); // ok >> b.bar("1"); // ok >> >> B.bar(1); // error: function expected before (), not 'bar' >> B.bar("1"); // error: function expected before (), not 'bar' >> } >> </code> >> >> Mixins have that bug too. > > |
July 19, 2004 Re: static overloaded method with parent overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Edwards | > Ilya Zaitseff wrote:
>
>> DMD 0.95 still have this bug:
>> <code>
>> template TA()
>> {
>> static void foo(int i) { }
>> }
>> struct B
>> {
>> mixin TA!() ta;
>> alias ta.foo foo;
>> static void foo(int i) { }
>> }
>> void main()
>> {
>> B.foo(1); // error: function expected before (), not 'foo'
>> }
>> </code>
>
> I'm learning here so maybe I've got this all wrong, but isn't one
> supposed to instantiate a struct prior to accessing it's members?
>
> shouldn't your main read this instead?
>
> void main()
> {
> B b;
> b.foo(1);
> }
>
> Just a thought!
>
No, because foo() is static, i.e. it is member of type, not type instance.
The following compiles successfully:
struct B
{
static void foo(int i) {}
}
void main()
{
B.foo(1);
}
The problem in mixins itself.
|
Copyright © 1999-2021 by the D Language Foundation