From 99601456e6ad4c86287ba786923c99c5499037e0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 6 Jan 2026 17:17:27 +0200 Subject: improve move checker to detect pointer leaks + Currently requires a lot of unnecessary `forget` statements, but at least some can likely be eliminated by doing some basic origin analysis, kind of like with groups --- src/ast.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index 9515775..a39cb94 100644 --- a/src/ast.c +++ b/src/ast.c @@ -570,10 +570,24 @@ struct type *reverse_type_list(struct type *root) void fix_closures(struct ast *root) { while (root) { - if (root->k != AST_CALL) { + if (root->k != AST_CALL && root->k != AST_NIL_CHECK) { root = root->n; continue; } + if (root->k == AST_NIL_CHECK) { + struct ast *next = root->n; + if (!next) + next = gen_empty(root->loc); + + struct ast *block = gen_block(next, root->loc); + nil_check_rest(root) = block; + root->n = NULL; + + root = next; + continue; + } + + /* call */ struct ast *arg = ast_last(call_args(root)); if (!arg) { root = root->n; -- cgit v1.2.3