From 11ca2d51b4c7dfe8bb914f6256182a39c966ccbd Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 3 Jul 2024 14:42:46 +0200 Subject: [PATCH] fix(fiber): Main fiber can't be cancelled --- src/builtin/fiber.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/builtin/fiber.zig b/src/builtin/fiber.zig index 5a049370..21383847 100644 --- a/src/builtin/fiber.zig +++ b/src/builtin/fiber.zig @@ -17,6 +17,11 @@ pub fn over(ctx: *NativeCtx) c_int { pub fn cancel(ctx: *NativeCtx) c_int { const self = ObjFiber.cast(ctx.vm.peek(0).obj()).?; + // Main fiber can't be cancelled + if (self.fiber.parent_fiber == null) { + return 0; + } + self.fiber.status = .Over; return 0;