From 04aec1a04a8c0750a9192d859ef6e4b9994cd58e Mon Sep 17 00:00:00 2001 From: Lukasz Czajka Date: Mon, 26 Jun 2023 10:30:24 +0200 Subject: [PATCH 1/3] fix internal-to-core letrec indices --- src/Juvix/Compiler/Core/Translation/FromInternal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Juvix/Compiler/Core/Translation/FromInternal.hs b/src/Juvix/Compiler/Core/Translation/FromInternal.hs index 9e1adfb568..9c3c78ec3b 100644 --- a/src/Juvix/Compiler/Core/Translation/FromInternal.hs +++ b/src/Juvix/Compiler/Core/Translation/FromInternal.hs @@ -514,7 +514,7 @@ goLet l = goClauses (toList (l ^. Internal.letClauses)) pragmas = map (^. Internal.funDefPragmas) lfuns tys' <- mapM goType tys localAddNames names $ do - vals' <- sequence [mkFunBody ty f | (ty, f) <- zipExact tys' lfuns] + vals' <- sequence [mkFunBody (shift (length names) ty) f | (ty, f) <- zipExact tys' lfuns] let items = nonEmpty' (zipWith3Exact (\ty n v -> LetItem (Binder (n ^. nameText) (Just $ n ^. nameLoc) ty) v) tys' names vals') rest <- goClauses cs return (mkLetRec (setInfoPragmas pragmas mempty) items rest) From 8262e68e5b295119d1c856ee3ebf9f257d4783ca Mon Sep 17 00:00:00 2001 From: Lukasz Czajka Date: Mon, 26 Jun 2023 10:55:34 +0200 Subject: [PATCH 2/3] fix lambda-lifting --- src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs index 201b291547..3e1d3e7a4c 100644 --- a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs +++ b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs @@ -159,7 +159,7 @@ lambdaLiftNode aboveBl top = ] declareTopSyms - let -- TODO it can probably be simplified + let -- TODO it can probably be simplified, and it's wrong shiftHelper :: Node -> NonEmpty (Node, Binder) -> Node shiftHelper b = goShift 0 where @@ -171,7 +171,7 @@ lambdaLiftNode aboveBl top = | otherwise -> impossible (y : ys) -> mkLet mempty bnd' (shift k x) (goShift (k + 1) (y :| ys)) where - bnd' = over binderType (shift k . subsCalls) bnd + bnd' = over binderType (shift k) bnd let res :: Node res = shiftHelper body' (nonEmpty' (zipExact letItems letRecBinders')) return (Recur res) From 1aa16855801602dbe01b964076577d00703e4c4d Mon Sep 17 00:00:00 2001 From: Lukasz Czajka Date: Mon, 26 Jun 2023 11:08:12 +0200 Subject: [PATCH 3/3] remove outdated comment --- src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs index 3e1d3e7a4c..9038305ab6 100644 --- a/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs +++ b/src/Juvix/Compiler/Core/Transformation/LambdaLetRecLifting.hs @@ -159,8 +159,7 @@ lambdaLiftNode aboveBl top = ] declareTopSyms - let -- TODO it can probably be simplified, and it's wrong - shiftHelper :: Node -> NonEmpty (Node, Binder) -> Node + let shiftHelper :: Node -> NonEmpty (Node, Binder) -> Node shiftHelper b = goShift 0 where goShift :: Int -> NonEmpty (Node, Binder) -> Node