Fixed some internal errors

This commit is contained in:
Rakarake 2023-03-21 15:59:47 +01:00
parent ec95e0d9ef
commit 71d07ebf0f

View file

@ -140,7 +140,7 @@ getExpType (T.ELit t _) = t
getExpType (T.EApp t _ _) = t getExpType (T.EApp t _ _) = t
getExpType (T.EAdd t _ _) = t getExpType (T.EAdd t _ _) = t
getExpType (T.EAbs t _ _) = t getExpType (T.EAbs t _ _) = t
getExpType (T.ELet _ _) = error "Lets not allowed🛑👮" getExpType (T.ELet _ _) = error "lets not allowed🛑👮"
-- | If ident not already in env's output, morphed bind to output -- | If ident not already in env's output, morphed bind to output
-- (and all referenced binds within this bind). -- (and all referenced binds within this bind).
@ -173,29 +173,31 @@ morphExp expectedType exp = case exp of
return $ M.EAdd expectedType e1' e2' return $ M.EAdd expectedType e1' e2'
-- Add local vars to locals, this will never be called after the lambda lifter -- Add local vars to locals, this will never be called after the lambda lifter
T.EAbs _ (ident, _) e -> do let (M.TArr _ t) = expectedType T.EAbs _ (ident, _) e -> do let (M.TArr _ t) = expectedType
error "should not be able to happen" error "EAbs found in Monomorpher, should not be possible"
addLocal ident addLocal ident
morphExp t e morphExp t e
T.EId (ident, t) -> do maybeLocal <- localExists ident T.EId (ident@(Ident istr), t) -> do
if maybeLocal then do maybeLocal <- localExists ident
t' <- getMonoFromPoly t if maybeLocal then do
return $ M.EId (ident, t') t' <- getMonoFromPoly t
else do return $ M.EId (ident, t')
clearLocals else do
bind <- getInputBind ident clearLocals
case bind of bind <- getInputBind ident
Nothing -> error "Wowzers!" case bind of
Just bind' -> do Nothing ->
maybeCurrentFunc <- isCurrentFunc ident error $ "bind of name: " ++ istr ++ " not found"
t' <- getMonoFromPoly t Just bind' -> do
if maybeCurrentFunc then -- Recursive call? maybeCurrentFunc <- isCurrentFunc ident
return () t' <- getMonoFromPoly t
else if maybeCurrentFunc then -- Recursive call?
morphBind t' bind' return ()
return $ M.EId (ident, t') else
morphBind t' bind'
return $ M.EId (ident, t')
T.ELet (T.Bind {}) _ -> error "Lets not possible yet." T.ELet (T.Bind {}) _ -> error "lets not possible yet"
-- Creates a new identifier for a function with an assigned type -- Creates a new identifier for a function with an assigned type
newName :: M.Type -> T.Bind -> Ident newName :: M.Type -> T.Bind -> Ident