diff --git a/lang/ast/expr/arith.c b/lang/ast/expr/arith.c index c3c1ded..fe49816 100644 --- a/lang/ast/expr/arith.c +++ b/lang/ast/expr/arith.c @@ -379,18 +379,28 @@ enum ivy_status expr_finalise_arith( op = op_node->n_op; tmp = b_queue_pop_back(&q); op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry); - op_node->n_right->n_parent = (struct ivy_ast_node *)op_node; - ivy_ast_node_extend_bounds_recursive( - (struct ivy_ast_node *)op_node, (struct ivy_ast_node *)tmp); + + if (op_node->n_right) { + op_node->n_right->n_parent = (struct ivy_ast_node *)op_node; + + ivy_ast_node_extend_bounds_recursive( + (struct ivy_ast_node *)op_node, + (struct ivy_ast_node *)tmp); + } if (op->op_arity == IVY_OP_BINARY) { tmp = b_queue_pop_back(&q); op_node->n_left = b_unbox(struct ivy_ast_node, tmp, n_entry); - op_node->n_left->n_parent = (struct ivy_ast_node *)op_node; - ivy_ast_node_extend_bounds_recursive( - (struct ivy_ast_node *)op_node, - (struct ivy_ast_node *)tmp); + + if (op_node->n_left) { + op_node->n_left->n_parent + = (struct ivy_ast_node *)op_node; + + ivy_ast_node_extend_bounds_recursive( + (struct ivy_ast_node *)op_node, + (struct ivy_ast_node *)tmp); + } } /* ...and push the newly-completed operator node to the operand