From: simonpj Date: Tue, 12 Mar 2002 09:13:08 +0000 (+0000) Subject: [project @ 2002-03-12 09:13:08 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~2286 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=65f44e3892531fb10318809df1205112e7696e6a;p=ghc-hetmet.git [project @ 2002-03-12 09:13:08 by simonpj] ----------- Fix mkSynTy ----------- Fix a nasty and long-lived bug in mkSynTy which meant that in: newtype A a = A a type B = A f :: B Double the type (B Double) wasn't regarded properly as (A Double). This bug has lasted for a long time because the type inference engine is fairly forgiving about missing the invariant that a TyConApp always looks like one right at the top level. In fact, it's so forgiving that I don't know how to tickle this bug into showing up. (It showed up in 5.02, becuase the context-simplification for 'deriving' is done by a different engine as all the other context simplification.) Still, the invariant should hold, and this fix makes it so. --- diff --git a/ghc/compiler/types/Type.lhs b/ghc/compiler/types/Type.lhs index dc642d0..526cf3d 100644 --- a/ghc/compiler/types/Type.lhs +++ b/ghc/compiler/types/Type.lhs @@ -358,7 +358,10 @@ mkSynTy tycon tys | n_args == arity -- Exactly saturated = mk_syn tys | n_args > arity -- Over-saturated - = case splitAt arity tys of { (as,bs) -> foldl AppTy (mk_syn as) bs } + = case splitAt arity tys of { (as,bs) -> mkAppTys (mk_syn as) bs } + -- Its important to use mkAppTys, rather than (foldl AppTy), + -- because (mk_syn as) might well return a partially-applied + -- type constructor; indeed, usually will! | otherwise -- Un-saturated = TyConApp tycon tys -- For the un-saturated case we build TyConApp directly