wren icon indicating copy to clipboard operation
wren copied to clipboard

Fiber.abort(null) continues execution

Open ruby0x1 opened this issue 3 years ago • 3 comments

Making a note to investigate this.

This one

System.print("hello wren")
Fiber.abort("end")
S:ystem.print("after abort")

gets the expected runtime error

hello wren
end
[compile line 2] in (script)

while this one

System.print("hello wren")
Fiber.abort(null)
System.print("after abort")

still prints

hello wren
after abort

ruby0x1 avatar Sep 22 '22 21:09 ruby0x1

This behavior is normal per definition of fiber error. A non null value in a fiber error indicates that a fiber is in an error state. Therefore a null value indicates there is no error, and trying setting it to null should behave as this.

That said it is a little bit not intuitive, but doing otherwise would requires to use other bytes or use the other null (undefined) to implement an optional value like interface...

mhermier avatar Sep 23 '22 11:09 mhermier

It's also as documented: If the message is null , does nothing.

Might even be useful for generating conditional errors.

Probably best left as it is.

PureFox48 avatar Sep 26 '22 08:09 PureFox48

thanks yea, I know it's documented, but it bit me when forwarding errors in larger scale projects so ✨

Making a note to investigate this.

ruby0x1 avatar Sep 26 '22 08:09 ruby0x1