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 on other sites

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 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 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);
"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 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 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 on other sites

I've fixed this in revision 2578

Create an account

Register a new account

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 11
• 9
• 23
• 18
• Forum Statistics

• Total Topics
634432
• Total Posts
3017392
×