From fa0df409979df995d4864af00b4ecf39b6d6c688 Mon Sep 17 00:00:00 2001 From: Tobias Mock Date: Wed, 2 Oct 2024 22:37:06 +0200 Subject: [PATCH] Fix recursive calls in local functions --- lib/monomorph_tree.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/monomorph_tree.ml b/lib/monomorph_tree.ml index 32819df..3a67eb0 100644 --- a/lib/monomorph_tree.ml +++ b/lib/monomorph_tree.ml @@ -1251,7 +1251,11 @@ and morph_app mk p callee args ret_typ = let app = Mapp { callee; args; alloca = alloc_ref; id; ms } in - ({ p with ret; mallocs }, mk app ret, { no_var with alloc; malloc; tailrec }) + (* We use tailrec here because the return state is only use for tailrec + detection in codegen. Ideally, we would set this more explicitly. *) + ( { p with ret; mallocs }, + mk app tailrec, + { no_var with alloc; malloc; tailrec } ) and morph_ctor mk p variant index expr typ = let ret = p.ret in