With current AngelScript SVN, I'm getting assert failures, when compiling scripts, either from tempVariables.GetLength() != 0, or the amount of variable allocations not matching free variables. Here's an example. The "node" handle is actually a global property, which will return non-null if the ScriptObject in question is attached to a scene node on the C++ side. It is also an auto handle.
class GameObject : ScriptObject
{
int health;
GameObject()
{
health = 10;
}
void Update(float deltaTime)
{
node.vars["Health"] = health; // This will cause unfreed temp variable of type Node@
}
}
Furthermore, some calls to C++ code that return an object handle (an auto handle, if that makes any difference) seem to now return null. This I can fix by putting back the first line in the code block below into asCCompiler::PerformFunctionCall(); the line was removed some time ago, as part of the fixes to the unsafe refs crash:
ctx->type.Set(descr->returnType); // this was removed
if( isConstructor )
{
// Sometimes the value types are allocated on the heap,
// which is when this way of constructing them is used.
Unfortunately I'm unable to construct a test easily, seems like the issue needs my full engine with the actual classes registered to manifest

In case they'll help, very abbreviated registrations of the (hopefully) relevant classes from the piece of code above: (some are same as in the unsafe ref crash)
engine->RegisterObjectType("String", sizeof(String), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterStringFactory("String", asFUNCTION(StringFactory), asCALL_CDECL);
engine->RegisterObjectType("Variant", sizeof(Variant), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(int)", asFUNCTION(ConstructVariantInt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectMethod("Variant", "Variant& opAssign(int)", asMETHODPR(Variant, operator =, (int), Variant&), asCALL_THISCALL);
engine->RegisterObjectType("VariantMap", sizeof(VariantMap), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
engine->RegisterObjectMethod("VariantMap", "Variant& opIndex(const String&in)", asFUNCTION(VariantMapAt), asCALL_CDECL_OBJLAST);
engine->RegisterObjectType("Node", 0, asOBJ_REF);
engine->RegisterObjectProperty("Node", "VariantMap vars", offsetof(Node, vars_));
engine->RegisterGlobalFunction("Node@+ get_node()", asFUNCTION(GetScriptContextNode), asCALL_CDECL);