diff options
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; |
