mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Fix wrenAbortFiber does not work inside of foreign class allocator
This commit is contained in:
@ -82,6 +82,13 @@ static void resourceFinalize(void* data)
|
||||
finalized++;
|
||||
}
|
||||
|
||||
static void badClassAllocate(WrenVM* vm)
|
||||
{
|
||||
wrenEnsureSlots(vm, 1);
|
||||
wrenSetSlotString(vm, 0, "Something went wrong");
|
||||
wrenAbortFiber(vm, 0);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn foreignClassBindMethod(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static ForeignClass.finalized") == 0) return apiFinalized;
|
||||
@ -114,4 +121,10 @@ void foreignClassBindClass(
|
||||
methods->finalize = resourceFinalize;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(className, "BadClass") == 0)
|
||||
{
|
||||
methods->allocate = badClassAllocate;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,3 +75,13 @@ resources.clear()
|
||||
|
||||
System.gc()
|
||||
System.print(ForeignClass.finalized) // expect: 3
|
||||
|
||||
// Class that aborts fiber
|
||||
foreign class BadClass {
|
||||
construct new() {}
|
||||
}
|
||||
|
||||
error = Fiber.new {
|
||||
BadClass.new()
|
||||
}.try()
|
||||
System.print(error) // expect: Something went wrong
|
||||
|
||||
Reference in New Issue
Block a user