isReturnStmt :: (ProverK loc m) => loc -> Set StmtClass -> Type -> TcM m ()
isReturnStmt l cs ret = do
    ppret <- pp ret
    ppcs <- pp cs
    addErrorM l (\err -> TypecheckerError (locpos l) $ NoReturnStatement (ppret <+> ppcs) $ Just err) $ mapM_ aux $ Set.toList cs
  where
    aux StmtReturn = return ()
    aux (StmtFallthru t) = do
        pp1 <- pp ret
        pp2 <- pp t
        addErrorM l (TypecheckerError (locpos l) . (EqualityException "expression") (pp1) (pp2) . Just) $
            tcCstrM_ l $ Unifies ret t
    aux x = genTcError (locpos l) False $ text "Unexpected return class"
isReturnStmt :: (ProverK loc m) => loc -> Set StmtClass -> Type -> TcM m ()
isReturnStmt l cs ret = do
    ppret <- pp ret
    ppcs <- pp cs
    addErrorM l (\err -> TypecheckerError (locpos l) $ NoReturnStatement (ppret <+> ppcs) $ Just err) $ mapM_ aux $ Set.toList cs
  where
    aux StmtReturn = return ()
    aux (StmtFallthru t) = do
        pp1 <- pp ret
        pp2 <- pp t
        addErrorM l (TypecheckerError (locpos l) . (EqualityException "expression") (pp1) (pp2) . Just) $
            tcCstrM_ l $ Unifies ret t
    aux x = genTcError (locpos l) False $ text "Unexpected return class"
isReturnStmt l cs ret = do
    ppret <- pp ret
    ppcs <- pp cs
    addErrorM l (\err -> TypecheckerError (locpos l) $ NoReturnStatement (ppret <+> ppcs) $ Just err) $ mapM_ aux $ Set.toList cs
  where
    aux StmtReturn = return ()
    aux (StmtFallthru t) = do
        pp1 <- pp ret
        pp2 <- pp t
        addErrorM l (TypecheckerError (locpos l) . (EqualityException "expression") (pp1) (pp2) . Just) $
            tcCstrM_ l $ Unifies ret t
    aux x = genTcError (locpos l) False $ text "Unexpected return class"