From: simonpj Date: Thu, 23 Aug 2001 08:43:30 +0000 (+0000) Subject: [project @ 2001-08-23 08:43:30 by simonpj] X-Git-Tag: Approximately_9120_patches~1114 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=de568761513c59bef17bb3bf2285f6c9d457bddf;p=ghc-hetmet.git [project @ 2001-08-23 08:43:30 by simonpj] ----------------------------------- Correct a horrible error in repType ----------------------------------- repType is meant to give the underlying representation of a type. But it wasn't taking account of the fact that *recursive* newtypes are still represented by a TyConApp. (Non-recursive ones behave much more like type synonyms now.) As a result, if we have newtype F = F (F->F) then Bad Things happen if we try to seq x::F. We decide whether to push an ordinary return address or a SEQ frame based on the type, and repType didn't expose the fact that F is represented by a function type. Aargh. codeGen/should_run/cg050 now tests for this. --- diff --git a/ghc/compiler/types/Type.lhs b/ghc/compiler/types/Type.lhs index be39f10..33cd4b1 100644 --- a/ghc/compiler/types/Type.lhs +++ b/ghc/compiler/types/Type.lhs @@ -398,15 +398,22 @@ repType looks through (b) synonyms (c) predicates (d) usage annotations + (e) [recursive] newtypes It's useful in the back end. +Remember, non-recursive newtypes get expanded as part of the SourceTy case, +but recursive ones are represented by TyConApps and have to be expanded +by steam. + \begin{code} repType :: Type -> Type -repType (ForAllTy _ ty) = repType ty -repType (NoteTy _ ty) = repType ty -repType (SourceTy p) = repType (sourceTypeRep p) -repType (UsageTy _ ty) = repType ty -repType ty = ty +repType (ForAllTy _ ty) = repType ty +repType (NoteTy _ ty) = repType ty +repType (SourceTy p) = repType (sourceTypeRep p) +repType (UsageTy _ ty) = repType ty +repType (TyConApp tc tys) | isNewTyCon tc && length tys == tyConArity tc + = repType (newTypeRep tc tys) +repType ty = ty splitRepFunTys :: Type -> ([Type], Type) -- Like splitFunTys, but looks through newtypes and for-alls