Skip to content

Conversation

@ianthehenry
Copy link
Contributor

The following code worked before Janet 1.39.0, but now errors:

repl:1:> (try (print "something") ([_ _] (print "oh no")))
something
error: bad slot #0, expected fiber, got nil
  in fiber/status [src/core/fiber.c] on line 596
  in thunk [repl] (tail call) on line 1, column 1

#1605 introduced a nicer way to ignore the "arguments" in the catch clause, but in doing so broke this pattern.

I realize that's equivalent to (try (print "something") ([_] (print "oh no"))), which still works, but I was used to writing the above to make it less likely that I would forget about the fiber argument if I changed code to something that wanted to re-raise. So upgrading to Janet 1.39.0 broke some code in the wild.

Allow re-using the same symbol for the fiber and error. This allows you to
write code like (try (print "hi") ([_ _] (print "oh no"))), fixing a regression
introduced in janet-lang#1605.
ianthehenry added a commit to ianthehenry/bauble that referenced this pull request Oct 25, 2025
This code should work regardless of the Janet version used, and we can back
it out after janet-lang/janet#1659 lands upstream.
@sogaiu
Copy link
Contributor

sogaiu commented Oct 25, 2025

Thanks for the report and the fix (and sorry we broke things!).

Would you mind adding a test to help prevent regressions?

@sogaiu
Copy link
Contributor

sogaiu commented Oct 25, 2025

Thanks for the tests!

@sogaiu
Copy link
Contributor

sogaiu commented Oct 25, 2025

FWIW, using 0c34033 I ran tests for most of my projects as well as spork's and they all turned out fine 👍

@bakpakin bakpakin merged commit 2a33080 into janet-lang:master Oct 25, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants