🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Failed assertion when compiling if statement checking get_X w/o existing set_X

Started by
6 comments, last by WitchLord 5 years, 5 months ago

Unsure exactly if this is the reason why the assertion fails, but it does make sense. The following assertion fails:


// We should never get here while the context is still an unprocessed property accessor
asASSERT(ctx->property_get == 0 && ctx->property_set == 0);

Above, property_get is some number, and property_set seems to be 0. ConvertToVariable is called from "asCCompiler::CompileIfStatement":


if( expr.type.dataType.IsReference() ) ConvertToVariable(&expr);

It happens when compiling the following if statement in the script:


if (g_serverDisplayNameTask.HasSucceeded) {

HasSucceeded is a read-only property, and therefore it's registered only as "bool get_HasSucceeded()". This used to never give me problems in prior (SVN/WIP) versions, I guess something changed?

I believe this also happens with while() loops. And, if the assertion is ignored, the returned value is just false.

Advertisement

Do you know which prior revision in the SVN you used before without the problem? I didn't make any changes related to this just before the release.

Anyway, I'll investigate and have it fixed.

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

I'm not entirely sure. The scripts that cause the issues are only on the build I use for development the least, so it might've been quite a bit back.. but probably somewhere after October 25th, at least. I know, that probably doesn't help much.. :/

I haven't managed to reproduce this problem. How is the g_serverDisplayNameTask variable registered? Can you give me both the code for registering the type and the property?

I have tried a few different variants of the code below, including registering it as value type, or the property as a handle, but none of my attempts have reproduced the problem. Can you show me what needs to change in the below snippet to reproduce the problem?


	{
		engine = asCreateScriptEngine();
		bout.buffer = "";
		engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
	
		r = engine->RegisterObjectType("Foo", 0, asOBJ_REF | asOBJ_NOCOUNT); assert( r >= 0 );
		r = engine->RegisterObjectMethod("Foo", "bool get_HasSucceeded()", asFUNCTION(0), asCALL_GENERIC); assert( r >= 0 );
		r = engine->RegisterGlobalProperty("Foo g_serverDisplayNameTask", (void*)1); assert( r >= 0 );
	
		mod = engine->GetModule(0, asGM_ALWAYS_CREATE); assert(mod != NULL);
		r = mod->AddScriptSection("test",
			"void test() \n"
			"{ \n"
			"  if( g_serverDisplayNameTask.HasSucceeded ) {} \n"
			"  while( g_serverDisplayNameTask.HasSucceeded ) {} \n"
			"  for( ; g_serverDisplayNameTask.HasSucceeded; ) {} \n"
			"} \n");
		r = mod->Build();
		if (r < 0)
			TEST_FAILED;
		if (bout.buffer != "")
		{
			PRINTF("%s", bout.buffer.c_str());
			TEST_FAILED;
		}
			
		r = engine->ShutDownAndRelease();
	}

 

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

Okay, I figured it out - the problem is that it returns a bool& rather than just a bool.

I will probably have to re-think how the API is registered in my API (really shouldn't need to be returning by reference honestly).

The reason I overlooked it at first is because I am generating these specific declarations automatically (with a formatting like "%s get_%s()" etc.), sorry about that.

That did it. While it may be unusual to return it by reference, it is legal and should work. 

I'll provide a fix as soon as possible.

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

I've fixed this in revision 2578

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