Skip to content

Commit

Permalink
fix(jit): Typo resulted in try/catch clause to never be reached
Browse files Browse the repository at this point in the history
closes #192
  • Loading branch information
giann committed Sep 26, 2023
1 parent 0412bca commit 8b19868
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mirjit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4462,8 +4462,8 @@ fn generateTry(self: *Self, try_node: *n.TryNode) Error!?m.MIR_op_t {
self.BEQ(
m.MIR_new_label_op(
self.ctx,
if (index < try_node.clauses.keys().len - 1)
clause_labels.items[index + 1]
if (idx < try_node.clauses.keys().len - 1)
clause_labels.items[idx + 1]
else if (unconditional_label) |unconditional|
unconditional
else
Expand Down
25 changes: 25 additions & 0 deletions tests/064-throw-inside-try.buzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "std";

fun willFail() > void !> str {
if (false) {
throw "Hey";
}
}

object SomeError {}

fun run() > void {
try {
willFail();

throw SomeError{};
} catch (str _) {
assert(false, message: "Could throw inside try/catch");
} catch (SomeError _) {
assert(true, message: "Could throw inside try/catch");
}
}

test "Throw inside try/catch" {
run();
}

0 comments on commit 8b19868

Please sign in to comment.