Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualAndreas Jonsson

Posted 21 March 2012 - 12:50 PM

My suspicion was incorrect. I've reduced the problem to the following script

class END_MenuItem : Widget
{
    END_MenuItem()
    {
    }
};
class Widget
{
    Widget( Widget@ parent = null )
    {
    }
};

The bug is caused when the base class doesn't have a default constructor, and the derived class doesn't explicitly call the base class' constructor with the appropriate arguments. As the compiler didn't see an explicit call to any of the base class' constructors it tries to call the default constructor which until version 2.22.1 was implemented automatically.

The correct behaviour in this case is for AngelScript to give an error message to tell the script writer to explicitly call the base constructor with super(...);.

I'll work on implementing this verification and appropriate error message, but until then you can work around the problem in 3 ways:

1. Explicitly call the base class' constructor with 'super(null);'
2. Implement a default constructor in the Widget class
3. Configure AngelScript to automatically provide the default constructor with engine->SetEngineProperty(asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true);

Regards,
Andreas

#1Andreas Jonsson

Posted 21 March 2012 - 12:49 PM

My suspicion was incorrect. I've reduced the problem to the following script


class END_MenuItem : Widget
{
END_MenuItem()
{
}
};
class Widget
{
Widget( Widget@ parent = null )
{
}
};

The bug is caused when the base class doesn't have a default constructor, and the derived class doesn't explicitly call the base class' constructor with the appropriate arguments. As the compiler didn't see an explicit call to any of the base class' constructors it tries to call the default constructor which until version 2.22.1 was implemented automatically.

The correct behaviour in this case is for AngelScript to give an error message to tell the script writer to explicitly call the base constructor with super(...);.

I'll work on implementing this verification and appropriate error message, but until then you can work around the problem in 3 ways:

1. Explicitly call the base class' constructor with 'super(null);'
2. Implement a default constructor in the Widget class
3. Configure AngelScript to automatically provide the default constructor with engine->SetEngineProperty(asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true);

Regards,
Andreas

PARTNERS