fix: propagate aborted fiber error check before call and unwind caller chain in runtimeError
Move the aborted fiber check in runFiber to execute before the "already called" check, ensuring a clear error message for aborted fibers. In runtimeError, replace the single caller unhook with a loop that walks the fiber chain, preserving the callerIsTrying flag and only unhooking fibers until a try-catch boundary is found, enabling proper error propagation through nested fiber calls. Add test cases for one and two levels of nested fiber try calls.
This commit is contained in:
@@ -8,3 +8,34 @@ System.print(fiber.try())
|
||||
// expect: before
|
||||
// expect: Bool does not implement 'unknownMethod'.
|
||||
System.print("after try") // expect: after try
|
||||
|
||||
var fiber2 = Fiber.new {
|
||||
var fiberInner = Fiber.new {
|
||||
System.print("before")
|
||||
true.unknownMethod
|
||||
System.print("after")
|
||||
}
|
||||
fiberInner.call()
|
||||
}
|
||||
|
||||
System.print(fiber2.try())
|
||||
// expect: before
|
||||
// expect: Bool does not implement 'unknownMethod'.
|
||||
System.print("after try") // expect: after try
|
||||
|
||||
var fiber3 = Fiber.new {
|
||||
var fiberInner = Fiber.new {
|
||||
var fiberInnerInner = Fiber.new {
|
||||
System.print("before")
|
||||
true.unknownMethod
|
||||
System.print("after")
|
||||
}
|
||||
fiberInnerInner.call()
|
||||
}
|
||||
fiberInner.call()
|
||||
}
|
||||
|
||||
System.print(fiber3.try())
|
||||
// expect: before
|
||||
// expect: Bool does not implement 'unknownMethod'.
|
||||
System.print("after try") // expect: after try
|
||||
|
||||
Reference in New Issue
Block a user