Advertisement

asBEHAVE_REF_CAST from type to itself

Started by April 28, 2014 07:48 PM
0 comments, last by WitchLord 10 years, 7 months ago

I meant to call this:


RegisterObjectBehaviour("Base", asBEHAVE_REF_CAST, "Derived@ f()", asFUNCTION((refCast<Base,Derived>)), asCALL_CDECL_OBJLAST)

But instead called this (note the typo):


RegisterObjectBehaviour("Derived", asBEHAVE_REF_CAST, "Derived@ f()", asFUNCTION((refCast<Base,Derived>)), asCALL_CDECL_OBJLAST)

There were no warnings or asserts from AS.. the Base-to-Derived cast in script didn't work (as we might expect).

I won't go as far as saying this is a bug (as in it should have triggered an assert).. but would it be possible/desirable to at least add a warning about it or something along those lines? What is the expected behavior here?

2.29.0 WIP (rev 1906), Linux 32bit

Thank you!

The expected behaviour here is that the ref-cast behaviour to itself will never be called. The compiler will always be looking for a ref-cast that returns a different type and will simply filter out this as any other cast behaviour that doesn't return the desired type.

I'll consider adding a specific verification in the engine for this case.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement