Advertisement

bug about undefined variable with constructor

Started by October 01, 2009 02:04 AM
3 comments, last by WitchLord 15 years, 1 month ago
try this simple script. void main() { string t = string(ti); //ti is undefined } I implement a string class with the following configuration r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f()", asFUNCTION(ConstructString), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const string ∈)", asFUNCTION(ConstructStringByString), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const bool)", asFUNCTION(ConstructStringByBool), asCALL_CDECL); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const uint)", asFUNCTION(ConstructStringByUInt), asCALL_CDECL); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const int)", asFUNCTION(ConstructStringByInt), asCALL_CDECL); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const float)", asFUNCTION(ConstructStringByFloat), asCALL_CDECL); r = engine->RegisterObjectBehaviour("string", asBEHAVE_FACTORY, "string @f(const double)", asFUNCTION(ConstructStringByDouble), asCALL_CDECL); And the angelscript compiler raise exception here! void asCCompiler::ImplicitConvObjectToObject(asSExprContext *ctx, const asCDataType &to, asCScriptNode *node, EImplicitConv convType, bool generateCode, asCArray<int> *reservedVars, bool allowObjectConstruct) { if( ctx->type.IsNullConstant() ) { if( to.IsObjectHandle() ) ctx->type.dataType = to; return; } if( to.GetObjectType() != ctx->type.dataType.GetObjectType() ) { if( ctx->type.dataType.GetObjectType()->Implements(to.GetObjectType()) ) //ctx->type.dataType is ttUnrecognizedToken, so GetObjectType() is NULL, which will raise an exception here { ctx->type.dataType.SetObjectType(to.GetObjectType()); } ............... } I use 2.17.0 with bytecode fix. Thanks a lot.
well i dont know for sure, but it doesn't look like terribly valid code, if you know "ti" is undefined, why are you expecting the script to compile?

Maybe I'm missing something. Either way, maybe use some source tags around your code snippets :P
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
He's complaining that the compiler is crashing; not that the code doesn't compile.
oohhh, check, got ya :P
==============================
A Developers Blog | Dark Rock Studios - My Site
Thanks for the precise bug report. I've found and fixed this problem. You can get the fix from the SVN (rev 487).

Regards,
Andreas

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