From 7420436ca19f76ab636c26b8ecc899224ca44820 Mon Sep 17 00:00:00 2001 From: Søren Sandmann Pedersen Date: Fri, 15 Jun 2012 19:14:49 -0400 Subject: Allow non-void function references to be assigned to void function variables --- interpret.c | 2 ++ type-check.c | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interpret.c b/interpret.c index d5b261d..defb194 100644 --- a/interpret.c +++ b/interpret.c @@ -496,4 +496,6 @@ interpret (ast_t *ast) current = next; } + + g_assert (stack->a->len == 0); } diff --git a/type-check.c b/type-check.c index fc1d149..f200d1a 100644 --- a/type-check.c +++ b/type-check.c @@ -153,11 +153,10 @@ compatible_functions (ast_function_type_spec_t *left, return report_error ("Incompatible argument types\n"); } - if ((is_void (left->return_) && !is_void (right->return_)) || - (is_void (right->return_) && !is_void (left->return_))) + if (!assignable (left->return_, right->return_) && + !is_void (left->return_)) { - return report_error ("Void and non-void functions " - "are not compatible\n"); + return FALSE; } return TRUE; -- cgit v1.2.3