commit 370029bac49b44a3f43fea025a89f44b2f20e8c7
parent b43ff202d210e6f6bfba87d2c63b038b6b6c91d7
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 6 Oct 2022 18:25:50 +0200
gen: run defers on assertion failure
Fixes: https://todo.sr.ht/~sircmpwn/hare/250
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/gen.c b/src/gen.c
@@ -795,6 +795,10 @@ gen_expr_assert(struct gen_context *ctx, const struct expression *expr)
msg = gen_expr(ctx, expr->assert.message);
}
+ for (struct gen_scope *scope = ctx->scope; scope; scope = scope->parent) {
+ gen_defers(ctx, scope);
+ }
+
struct qbe_value qmsg = mkqval(ctx, &msg);
pushi(ctx->current, NULL, Q_CALL, &rtfunc, &qmsg, NULL);