summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-10-09 09:51:35 +0200
committerTom Smeding <tom@tomsmeding.com>2021-10-09 09:51:35 +0200
commite0eaa85475fa685351f4d609de2893c24e05f1e0 (patch)
treeee9743ee12687082f0106357c6aba21c015d9875
parent4a782ea40ccb2043d96d437d5718cdf2c27a546f (diff)
Fix lazy-storing behaviour of Pair
-rw-r--r--SC/Exp.hs12
1 files changed, 8 insertions, 4 deletions
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