Skip to content

Commit

Permalink
subst in result type of let in inference mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sweirich committed Jun 29, 2022
1 parent 47a07a5 commit 5f20e2a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions full/src/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ tcTerm (Let rhs bnd) mty = do
aty <- inferType rhs
ty <- Env.extendCtxs [mkSig x aty, Def x rhs] $
tcTerm body mty
when (x `elem` Unbound.toListOf Unbound.fv ty) $
Env.err [DS "Let bound variable", DD x, DS "escapes in type", DD ty]
return ty
case mty of
Just _ -> return ty
Nothing -> return $ Unbound.subst x rhs ty

-- Type constructor application
tcTerm (TCon c params) Nothing = do
Expand Down
6 changes: 3 additions & 3 deletions main/src/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ tcTerm (Let rhs bnd) mty = {- SOLN HW -} do
aty <- inferType rhs
ty <- Env.extendCtxs [mkSig x aty, Def x rhs] $
tcTerm body mty
when (x `elem` Unbound.toListOf Unbound.fv ty) $
Env.err [DS "Let bound variable", DD x, DS "escapes in type", DD ty]
return ty
case mty of
Just _ -> return ty
Nothing -> return $ Unbound.subst x rhs ty
{- STUBWITH Env.err [DS "unimplemented"] -}
{- SOLN DATA -}
-- Type constructor application
Expand Down
6 changes: 3 additions & 3 deletions version2/src/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ tcTerm (Let rhs bnd) mty = do
aty <- inferType rhs
ty <- Env.extendCtxs [mkSig x aty, Def x rhs] $
tcTerm body mty
when (x `elem` Unbound.toListOf Unbound.fv ty) $
Env.err [DS "Let bound variable", DD x, DS "escapes in type", DD ty]
return ty
case mty of
Just _ -> return ty
Nothing -> return $ Unbound.subst x rhs ty



Expand Down
6 changes: 3 additions & 3 deletions version3/src/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ tcTerm (Let rhs bnd) mty = do
aty <- inferType rhs
ty <- Env.extendCtxs [mkSig x aty, Def x rhs] $
tcTerm body mty
when (x `elem` Unbound.toListOf Unbound.fv ty) $
Env.err [DS "Let bound variable", DD x, DS "escapes in type", DD ty]
return ty
case mty of
Just _ -> return ty
Nothing -> return $ Unbound.subst x rhs ty



Expand Down

0 comments on commit 5f20e2a

Please sign in to comment.