Jump to content
  • Advertisement
Sign in to follow this  
Miss

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

Recommended Posts

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.

Edited by Miss

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.. :/

Share this post


Link to post
Share on other sites

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();
	}

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!