Fixed woring order of monomorphization in ECase

This commit is contained in:
Rakarake 2023-05-03 15:08:07 +02:00
parent e70eae776a
commit 4038f34cc5

View file

@ -47,7 +47,6 @@ import Data.Coerce (coerce)
import Data.Map qualified as Map
import Data.Maybe (catMaybes)
import Data.Set qualified as Set
--import Debug.Trace
import Grammar.Print (printTree)
{- | EnvM is the monad containing the read-only state as well as the
@ -232,8 +231,8 @@ morphExp expectedType exp = case exp of
morphExp t' exp
T.ECase (exp, t) bs -> do
t' <- getMonoFromPoly t
bs' <- mapM morphBranch bs
exp' <- morphExp t' exp
bs' <- mapM morphBranch bs
return $ M.ECase (exp', t') (catMaybes bs')
-- Ideally constructors should be EInj, though this code handles them
-- as well.
@ -263,9 +262,6 @@ morphExp expectedType exp = case exp of
exp' <- morphExp tExp' exp
return $ M.ELet (M.Bind (identB, tB') [] (expB', tExpB')) (exp', tExp')
-- ELet (Bind' t) (ExpT' t)
-- Bind (Id' t) [Id' t] (ExpT' t)
-- | Monomorphizes case-of branches.
morphBranch :: T.Branch -> EnvM (Maybe M.Branch)
morphBranch (T.Branch (p, pt) (e, et)) = do