Fixed small bug in monomorphizer

This commit is contained in:
Rakarake 2023-04-17 15:53:16 +02:00
parent c2bf6312f6
commit a23269f907
2 changed files with 6 additions and 5 deletions

View file

@ -1,5 +1,6 @@
const x y = x;
const x y = x
f x = (const x 'c');
f x = (const x 'c')
main = f 5
main = f 5;

View file

@ -120,7 +120,7 @@ getMonoFromPoly t = do env <- ask
-- Returns the annotated bind name.
-- TODO: Redundancy? btype and t should always be the same.
morphBind :: M.Type -> T.Bind -> EnvM Ident
morphBind expectedType b@(T.Bind (Ident _, btype) args (exp, expt)) =
morphBind expectedType b@(T.Bind (Ident str, btype) args (exp, expt)) =
local (\env -> env { locals = Set.fromList (map fst args),
polys = Map.fromList (mapTypes btype expectedType)
}) $ do
@ -137,7 +137,7 @@ morphBind expectedType b@(T.Bind (Ident _, btype) args (exp, expt)) =
-- Get monomorphic type sof args
args' <- mapM convertArg args
addOutputBind $ M.Bind (coerce name', expectedType)
args' (exp', expectedType)
args' (exp', expt')
return name'
convertArg :: (Ident, T.Type) -> EnvM (Ident, M.Type)