|
@@ -146,11 +146,18 @@ let make_module ctx mpath file tdecls loadp =
|
|
|
if List.mem AInline f.cff_access then error "MultiType constructors cannot be inline" f.cff_pos;
|
|
|
if fu.f_expr <> None then error "MultiType constructors cannot have a body" f.cff_pos;
|
|
|
end;
|
|
|
+ let has_call e =
|
|
|
+ let rec loop e = match fst e with
|
|
|
+ | ECall _ -> raise Exit
|
|
|
+ | _ -> Ast.map_expr loop e
|
|
|
+ in
|
|
|
+ try ignore(loop e); false with Exit -> true
|
|
|
+ in
|
|
|
let fu = {
|
|
|
fu with
|
|
|
f_expr = (match fu.f_expr with
|
|
|
| None -> if Meta.has Meta.MultiType a.a_meta then Some (EConst (Ident "null"),p) else None
|
|
|
- | Some (EBlock [EBinop (OpAssign,(EConst (Ident "this"),_),e),_],_ | EBinop (OpAssign,(EConst (Ident "this"),_),e),_) ->
|
|
|
+ | Some (EBlock [EBinop (OpAssign,(EConst (Ident "this"),_),e),_],_ | EBinop (OpAssign,(EConst (Ident "this"),_),e),_) when not (has_call e) ->
|
|
|
Some (EReturn (Some e), pos e)
|
|
|
| Some (EBlock el,p) -> Some (EBlock (init p :: el @ [ret p]),p)
|
|
|
| Some e -> Some (EBlock [init p;e;ret p],p)
|