www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - static overloaded method with parent overload

reply Sark7 <sark7 mail333.com> writes:
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.
Jun 21 2004
parent reply "Ilya Zaitseff" <sark7 mail333.com> writes:
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.
Jul 17 2004
parent reply Andrew Edwards <ridimz_at yahoo.dot.com> writes:
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.
Jul 17 2004
parent "Ilya Zaitseff" <sark7 mail333.com> writes:
 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.
Jul 18 2004