1. 21 Mar, 2019 1 commit
    • Ryan Scott's avatar
      Reject nested predicates in impredicativity checking · 8d18a873
      Ryan Scott authored
      When GHC attempts to unify a metavariable with a type containing
      foralls, it will be rejected as an occurrence of impredicativity.
      GHC was /not/ extending the same treatment to predicate types, such
      as in the following (erroneous) example from #11514:
      
      ```haskell
      foo :: forall a. (Show a => a -> a) -> ()
      foo = undefined
      ```
      
      This will attempt to instantiate `undefined` at
      `(Show a => a -> a) -> ()`, which is impredicative. This patch
      catches impredicativity arising from predicates in this fashion.
      
      Since GHC is pickier about impredicative instantiations, some test
      cases needed to be updated to be updated so as not to fall afoul of
      the new validity check. (There were a surprising number of
      impredicative uses of `undefined`!) Moreover, the `T14828` test case
      now has slightly less informative types shown with `:print`. This is
      due to a a much deeper issue with the GHCi debugger (see #14828).
      
      Fixes #11514.
      8d18a873
  2. 19 Feb, 2019 1 commit
  3. 07 Jun, 2018 2 commits
    • Ben Gamari's avatar
      testsuite: Fix dynamic-paper stderr file · 1508600c
      Ben Gamari authored
      The stderr file was empty, yet GHC fails with an error.
      1508600c
    • Simon Peyton Jones's avatar
      Remove ad-hoc special case in occAnal · c16382d5
      Simon Peyton Jones authored
      Back in 1999 I put this ad-hoc code in the Case-handling
      code for occAnal:
      
        occAnal env (Case scrut bndr ty alts)
         = ...
              -- Note [Case binder usage]
              -- ~~~~~~~~~~~~~~~~~~~~~~~~
              -- The case binder gets a usage of either "many" or "dead", never "one".
              -- Reason: we like to inline single occurrences, to eliminate a binding,
              -- but inlining a case binder *doesn't* eliminate a binding.
              -- We *don't* want to transform
              --      case x of w { (p,q) -> f w }
              -- into
              --      case x of w { (p,q) -> f (p,q) }
          tag_case_bndr usage bndr
            = (usage', setIdOccInfo bndr final_occ_info)
            where
              occ_info       = lookupDetails usage bndr
              usage'         = usage `delDetails` bndr
              final_occ_info = case occ_info of IAmDead -> IAmDead
                                                _       -> noOccInfo
      
      But the comment looks wrong -- the bad inlining will not happen -- and
      I think it relates to some long-ago version of the simplifier.
      
      So I simply removed the special case, which gives more accurate
      occurrence-info to the case binder.  Interestingly I got a slight
      improvement in nofib binary sizes.
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
      --------------------------------------------------------------------------------
            cacheprof          -0.1%     +0.2%     -0.7%     -1.2%     +8.6%
      --------------------------------------------------------------------------------
                  Min          -0.2%      0.0%    -14.5%    -30.5%      0.0%
                  Max          -0.1%     +0.2%    +10.0%    +10.0%    +25.0%
       Geometric Mean          -0.2%     +0.0%     -1.9%     -5.4%     +0.3%
      
      I have no idea if the improvement in runtime is real.  I did look at the
      tiny increase in allocation for cacheprof and concluded that it was
      unimportant (I forget the details).
      
      Also the more accurate occ-info for the case binder meant that some
      inlining happens in one pass that previously took successive passes
      for the test dependent/should_compile/dynamic-paper (which has a
      known Russel-paradox infinite loop in the simplifier).
      
      In short, a small win: less ad-hoc complexity and slightly smaller
      binaries.
      c16382d5
  4. 18 Jan, 2012 1 commit
  5. 16 Aug, 2011 1 commit