Thread overview
static overloaded method with parent overload
Jun 21, 2004
Sark7
Jul 17, 2004
Ilya Zaitseff
Jul 17, 2004
Andrew Edwards
Jul 19, 2004
Ilya Zaitseff
June 21, 2004
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
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
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
> 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.