wren-lang / wren

The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.
http://wren.io
MIT License
6.86k stars 550 forks source link

Fiber.abort(null) continues execution #1105

Open ruby0x1 opened 1 year ago

ruby0x1 commented 1 year ago

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
mhermier commented 1 year ago

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...

PureFox48 commented 1 year ago

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.

ruby0x1 commented 1 year ago

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.