FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inheritance: Constructor bug

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
randomZ



Joined: 04 Dec 2004
Posts: 31
Location: Tuebingen, Germany

PostPosted: Mon Oct 08, 2007 4:37 am    Post subject: Inheritance: Constructor bug Reply with quote

Hi,

I ran into something I think is faulty behaviour. Consider this small module:

Code:
module test;

class A
{
    this()
    {
        writefln("A ctor");
    }
}

class B : A
{
    this()
    {
        writefln("B ctor");
        super();
    }
}

class C : B
{
    this()
    {
        writefln("C ctor");
        super();
    }
}

local c = C();


This code will endlessly repeat the B constructor, never calling the A constructor.

Is there a possibility to have this behaviour fixed? It's quite critical for my project. Sad Or am I just not getting the MiniD semantics right?

Other than that, thanks for MiniD. I had always been afraid of scripting before I found it... it's very easy to integrate and works like a charm. Smile

Thanks
Sebastian
Back to top
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Oct 08, 2007 7:39 am    Post subject: Reply with quote

Oh, my, that is an issue. I think I can fix it. Basically it's working "correctly", at least as far as the way MiniD figures out the base class's constructor. But I guess that way is not quite right..

Until I release a fix, you can use the following. Basically, replace all calls to "super(...)" with "Class.super.constructor(with this, ...)", where Class is the current class.

Code:
class A
{
   this()
   {
      writefln("A ctor");
   }
}

class B : A
{
   this()
   {
      writefln("B ctor");
      B.super.constructor(with this);
   }
}

class C : B
{
   this()
   {
      writefln("C ctor");
      C.super.constructor(with this);
   }
}

local c = C();


This issue also seems to affect super method calls as well, so I hope to have this fixed very soon.
Back to top
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Oct 08, 2007 10:27 am    Post subject: Reply with quote

Aaand it's fixed. Grab the /tags/oct8-2007-1.1 repo. Smile
Back to top
View user's profile Send private message
randomZ



Joined: 04 Dec 2004
Posts: 31
Location: Tuebingen, Germany

PostPosted: Tue Oct 09, 2007 4:58 am    Post subject: Reply with quote

Whoa, that was quick. Thanks, I'll give it a try later today. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group