|
@@ -571,12 +571,16 @@ let type_function ctx args ret fmode f p =
|
|
|
add_local ctx n t, c
|
|
add_local ctx n t, c
|
|
|
) args in
|
|
) args in
|
|
|
let old_ret = ctx.ret in
|
|
let old_ret = ctx.ret in
|
|
|
|
|
+ let old_ret_exprs = ctx.ret_exprs in
|
|
|
let old_fun = ctx.curfun in
|
|
let old_fun = ctx.curfun in
|
|
|
let old_opened = ctx.opened in
|
|
let old_opened = ctx.opened in
|
|
|
ctx.curfun <- fmode;
|
|
ctx.curfun <- fmode;
|
|
|
ctx.ret <- ret;
|
|
ctx.ret <- ret;
|
|
|
|
|
+ ctx.ret_exprs <- [];
|
|
|
ctx.opened <- [];
|
|
ctx.opened <- [];
|
|
|
let e = type_expr ctx (match f.f_expr with None -> error "Function body required" p | Some e -> e) false in
|
|
let e = type_expr ctx (match f.f_expr with None -> error "Function body required" p | Some e -> e) false in
|
|
|
|
|
+ let t = unify_min ctx ctx.ret_exprs in
|
|
|
|
|
+ unify ctx t ctx.ret e.epos;
|
|
|
let rec loop e =
|
|
let rec loop e =
|
|
|
match e.eexpr with
|
|
match e.eexpr with
|
|
|
| TReturn (Some _) -> raise Exit
|
|
| TReturn (Some _) -> raise Exit
|
|
@@ -617,6 +621,7 @@ let type_function ctx args ret fmode f p =
|
|
|
in
|
|
in
|
|
|
List.iter (fun r -> r := Closed) ctx.opened;
|
|
List.iter (fun r -> r := Closed) ctx.opened;
|
|
|
ctx.ret <- old_ret;
|
|
ctx.ret <- old_ret;
|
|
|
|
|
+ ctx.ret_exprs <- old_ret_exprs;
|
|
|
ctx.curfun <- old_fun;
|
|
ctx.curfun <- old_fun;
|
|
|
ctx.opened <- old_opened;
|
|
ctx.opened <- old_opened;
|
|
|
e , fargs
|
|
e , fargs
|