From e0eaa85475fa685351f4d609de2893c24e05f1e0 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 9 Oct 2021 09:51:35 +0200 Subject: Fix lazy-storing behaviour of Pair --- SC/Exp.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'SC') diff --git a/SC/Exp.hs b/SC/Exp.hs index 5ddd4bf..5c0bc72 100644 --- a/SC/Exp.hs +++ b/SC/Exp.hs @@ -91,10 +91,14 @@ compileExp' aenv env = \case A.Pair a b -> do (usedA1, res1) <- compileExp' aenv env a (usedA2, res2) <- compileExp' aenv env b - return (usedA1 ++ usedA2, Left (\case - ITupPair n1 n2 -> toStoring res1 n1 ++ toStoring res2 n2 - ITupIgnore -> [] - ITupSingle _ -> error "wat")) + return (usedA1 ++ usedA2 + ,case (res1, res2) of + (Right (sts1, exp1), Right (sts2, exp2)) -> + Right (sts1 ++ sts2, ITupPair exp1 exp2) + _ -> Left (\case + ITupPair n1 n2 -> toStoring res1 n1 ++ toStoring res2 n2 + ITupIgnore -> [] + ITupSingle _ -> error "wat")) A.Const ty x | Just str <- showExpConst ty x -- cgit v1.2.3-70-g09d2