From: Matthijs Kooijman Date: Sun, 21 Jun 2009 15:24:29 +0000 (+0200) Subject: Don't propagate types with free tyvars. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=f18e8ab055de511846f09efc7752628013142d0f;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Don't propagate types with free tyvars. Any free type variables in a type argument wouldn't be in scope in the new function. Eventually, beta reducation and applicable inlining should make sure that all type variables are resolved. --- diff --git a/Normalize.hs b/Normalize.hs index d06670c..0d58d04 100644 --- a/Normalize.hs +++ b/Normalize.hs @@ -294,8 +294,10 @@ appsimpltop = everywhere ("appsimpl", appsimpl) typeprop, typeproptop :: Transform -- Transform any function that is applied to a type argument. Since type -- arguments are always the first ones to apply and we'll remove all type --- arguments, we can simply do them one by one. -typeprop expr@(App (Var f) (Type ty)) = do +-- arguments, we can simply do them one by one. We only propagate type +-- arguments without any free tyvars, since tyvars those wouldn't be in scope +-- in the new function. +typeprop expr@(App (Var f) arg@(Type ty)) | not $ has_free_tyvars arg = do id <- cloneVar f let newty = Type.applyTy (Id.idType f) ty let newf = Var.setVarType id newty