aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
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;