aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-01-06 17:17:27 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-01-06 17:19:52 +0200
commit99601456e6ad4c86287ba786923c99c5499037e0 (patch)
tree7f834f015cfc5c14e695e0521ae31c4262254dba /src/ast.c
parent64146b46da45ce69ab380add00459f7b60fe9196 (diff)
downloadfwd-99601456e6ad4c86287ba786923c99c5499037e0.tar.gz
fwd-99601456e6ad4c86287ba786923c99c5499037e0.zip
improve move checker to detect pointer leaksHEADmastergnc
+ 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
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c16
1 files changed, 15 insertions, 1 deletions
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;