Incorrect results from functions returning function handles.

This topic is 950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Running AngelScript 2.31.1 WIP revision 2319, I have a script method registered in the following way:

ASengine->RegisterObjectMethod("Object", "func@ opCast()", asMETHOD(Object, operator asIScriptFunction*), asCALL_THISCALL);


where Object is a class and func is a funcdef. The method is implemented in such a way that it may return both null and non-null handles, but all results are considered null by the following script:

void main() {
Object o;
if (cast<func@>(o) is null)
print("null");
}


I attempted to reproduce this using only a script, but the bug seems to occur only in application-registered functions. I spent some time debugging, and from what I understand, the function handle is erroneously placed into valueRegister instead of objectRegister because line 726 of as_callfunc.cpp doesn't predict function handles as returned types. Modifying the line to

if ( (descr->returnType.IsObject() || descr->returnType.IsFuncdef()) && !descr->returnType.IsReference() )


appears to fix the problem in this case.

Share on other sites

Thanks. Looks like you're correct. I'll have it fixed a.s.a.p.

Share on other sites

I've fixed this in revision 2320.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633701
• Total Posts
3013441
×