Just (abs_vars, _) -> abs_vars
Nothing -> [v]
- add_tyvars v | isId v = v : varSetElems (idFreeTyVars v)
- | otherwise = [v]
+ add_tyvars v = v : varSetElems (varTypeTyVars v)
-- We are going to lambda-abstract, so nuke any IdInfo,
-- and add the tyvars of the Id (if necessary)
returnUs (env', vs2)
-- VERY IMPORTANT: we must zap the demand info
- -- if the thing is going to float out past a lambda
+ -- if the thing is going to float out past a lambda,
+ -- or if it's going to top level (where things can't be strict)
zap_demand dest_lvl ctxt_lvl id
- | ctxt_lvl == dest_lvl = id -- Stays put
- | otherwise = zapDemandIdInfo id -- Floats out
+ | ctxt_lvl == dest_lvl,
+ not (isTopLvl dest_lvl) = id -- Stays, and not going to top level
+ | otherwise = zapDemandIdInfo id -- Floats out
\end{code}