diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-01-06 17:17:27 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-01-06 17:19:52 +0200 |
| commit | 99601456e6ad4c86287ba786923c99c5499037e0 (patch) | |
| tree | 7f834f015cfc5c14e695e0521ae31c4262254dba /src/ast.c | |
| parent | 64146b46da45ce69ab380add00459f7b60fe9196 (diff) | |
| download | fwd-99601456e6ad4c86287ba786923c99c5499037e0.tar.gz fwd-99601456e6ad4c86287ba786923c99c5499037e0.zip | |
+ 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.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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; |
