1. 08 May, 2018 2 commits
    • Ben Gamari's avatar
      Normalize the element type of ListPat, fix #14547 · 981bf471
      Ben Gamari authored
      The element type of `List` maybe a type family instacen, rather than a
      trivial type.
      For example in Trac #14547,
      
      ```
      {-# LANGUAGE TypeFamilies, OverloadedLists #-}
      
      class Foo f where
              type It f
              foo :: [It f] -> f
      
      data List a = Empty | a :! List a deriving Show
      
      instance Foo (List a) where
              type It (List a) = a
              foo [] = Empty
              foo (x : xs) = x :! foo xs
      ```
      
      Here the element type of `[]` is `It (List a)`, we should also normalize
      it as `a`.
      
      Test Plan: make test TEST="T14547"
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14547
      
      Differential Revision: https://phabricator.haskell.org/D4624
      981bf471
    • Ben Gamari's avatar
      Revert "Normalize the element type of ListPat, fix #14547" · 280de0c1
      Ben Gamari authored
      This reverts commit 361d23a8.
      280de0c1
  2. 05 May, 2018 1 commit
    • Tao He's avatar
      Normalize the element type of ListPat, fix #14547 · 361d23a8
      Tao He authored
      The element type of `List` maybe a type family instacen, rather than a
      trivial type.  For example in Trac #14547,
      
      ```
      {-# LANGUAGE TypeFamilies, OverloadedLists #-}
      
      class Foo f where
              type It f
              foo :: [It f] -> f
      
      data List a = Empty | a :! List a deriving Show
      
      instance Foo (List a) where
              type It (List a) = a
              foo [] = Empty
              foo (x : xs) = x :! foo xs
      ```
      
      Here the element type of `[]` is `It (List a)`, we should also normalize
      it as `a`.
      
      Test Plan: make test TEST="T14547"
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14547
      
      Differential Revision: https://phabricator.haskell.org/D4624
      361d23a8
  3. 27 Apr, 2018 1 commit
    • Alan Zimmerman's avatar
      TTG : complete for balance of hsSyn AST · c3823cba
      Alan Zimmerman authored
      Summary:
      - remove PostRn/PostTc fields
      - remove the HsVect In/Out distinction for Type, Class and Instance
      - remove PlaceHolder in favour of NoExt
      - Simplify OutputableX constraint
      
      Updates haddock submodule
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari
      
      Subscribers: goldfire, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4625
      c3823cba
  4. 09 Apr, 2018 1 commit
  5. 02 Mar, 2018 2 commits
    • Ryan Scott's avatar
      Fix the coverage checker's treatment of existential tyvars · a2d03c69
      Ryan Scott authored
      Previously, the pattern-match coverage checker was far too
      eager to freshen the names of existentially quantified type
      variables, which led to incorrect sets of type constraints that
      misled GHC into thinking that certain programs that involve nested
      GADT pattern matches were non-exhaustive (when in fact they were).
      Now, we generate extra equality constraints in the ConCon case of
      the coverage algorithm to ensure that these fresh tyvars align
      with existing existential tyvars. See
      `Note [Coverage checking and existential tyvars]` for the full story.
      
      Test Plan: make test TEST="T11984 T14098"
      
      Reviewers: gkaracha, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #11984, #14098
      
      Differential Revision: https://phabricator.haskell.org/D4434
      a2d03c69
    • Tao He's avatar
      Improve exhaustive checking for guards in pattern bindings and MultiIf. · e8e9f6a7
      Tao He authored
      Previously we didn't do exhaustive checking on MultiIf expressions
      and guards in pattern bindings.
      
      We can construct the `LMatch` directly from GRHSs or [LHsExpr]
      (MultiIf's alts) then feed it to checkMatches, without construct the
      MatchGroup and using function `matchWrapper`.
      Signed-off-by: Tao He's avatarHE, Tao <sighingnow@gmail.com>
      
      Test Plan: make test TEST="T14773a T14773b"
      
      Reviewers: bgamari, RyanGlScott, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14773
      
      Differential Revision: https://phabricator.haskell.org/D4400
      e8e9f6a7
  6. 14 Dec, 2017 1 commit
    • carlostome's avatar
      Fix #14135 by validity checking matches · 16c7d9dc
      carlostome authored
      We filter the complete patterns given in a COMPLETE set to only those that
      subsume the type we are matching. Otherwise we end up introducing an ill-typed
      equation into the overlap checking, provoking a crash. This was the cause of
      Trac #14135.
      
      Reviewers: austin, bgamari, mpickering, gkaracha, simonpj, RyanGlScott,
      carlostome
      
      Reviewed By: bgamari
      
      Subscribers: carter, dfeuer, RyanGlScott, goldfire, rwbarton, thomie
      
      GHC Trac Issues: #14135
      
      Differential Revision: https://phabricator.haskell.org/D3981
      16c7d9dc
  7. 21 Nov, 2017 1 commit
    • Ben Gamari's avatar
      Revert "trees that grow" work · 314bc314
      Ben Gamari authored
      As documented in #14490, the Data instances currently blow up
      compilation time by too much to stomach. Alan will continue working on
      this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid
      having to perform painful cherry-picks in 8.2 minor releases.
      
      Reverts haddock submodule.
      
      This reverts commit 47ad6578.
      This reverts commit e3ec2e7a.
      This reverts commit 438dd1cb.
      This reverts commit 0ff152c9.
      314bc314
  8. 11 Nov, 2017 1 commit
  9. 08 Nov, 2017 1 commit
  10. 07 Nov, 2017 2 commits
  11. 30 Oct, 2017 1 commit
  12. 11 Oct, 2017 1 commit
    • Simon Peyton Jones's avatar
      Minor refactoring · 461c8316
      Simon Peyton Jones authored
      I'm trying to understand Check.hs.  This patch is a very
      minor refactoring.  No change in behaviour.
      461c8316
  13. 27 Sep, 2017 1 commit
  14. 25 Sep, 2017 1 commit
  15. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  16. 31 Aug, 2017 1 commit
  17. 12 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Change isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedType · 4f1f9868
      Ryan Scott authored
      Summary:
      In a267580e, I somewhat awkwardly
      inserted a special case for `TYPE` in the `EmptyCase` coverage checker.
      Instead of placing it there, @mpickering noted that `isClosedAlgType` would
      be a better fit for it. I do just that in this patch.
      
      I also renamed `isClosedAlgType` to `pmIsClosedType`, reflecting the fact that
      `TYPE` technically isn't an algebraic type (it's a primitive one), and that its
      behavior is pattern-match coverage checking-oriented. I also moved it to
      `Check`, which is a better home for this function than `Type`. Luckily,
      the only call sites for `isClosedAlgType` were in the pattern-match coverage
      checker anyways, so this change is simple enough.
      
      Test Plan: ./validate
      
      Reviewers: mpickering, austin, goldfire, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie, mpickering
      
      GHC Trac Issues: #14086
      
      Differential Revision: https://phabricator.haskell.org/D3830
      4f1f9868
  18. 05 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Don't warn when empty casing on Type · a267580e
      Ryan Scott authored
      Summary:
      `Type` (a.k.a. `TYPE LiftedRep`) can be used at the type level thanks
      to `TypeInType`. However, expressions like
      
      ```lang=haskell
      f :: Type -> Int
      f x = case x of {}
      ```
      
      were falsely claiming that the empty case on the value of type `Type` was
      non-exhaustive. The reason is a bit silly: `TYPE` is technically not an empty
      datatype in GHC's eyes, since it's a builtin, primitive type. To convince the
      pattern coverage checker otherwise, this adds a special case for `TYPE`.
      
      Test Plan: make test TEST=T14086
      
      Reviewers: gkaracha, austin, bgamari, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: goldfire, rwbarton, thomie
      
      GHC Trac Issues: #14086
      
      Differential Revision: https://phabricator.haskell.org/D3819
      a267580e
  19. 31 Jul, 2017 2 commits
  20. 28 Jul, 2017 1 commit
    • Simon Peyton Jones's avatar
      Fix instantiation of pattern synonyms · 6b77914c
      Simon Peyton Jones authored
      In Check.hs (pattern match ovelap checking) we to figure out the
      instantiation of a pattern synonym from the type of the pattern. We
      were doing this utterly wrongly.  Trac #13768 demonstrated this
      bogosity.
      
      The fix is easy; and is described in PatSyn.hs
        Note [Pattern synonym result type]
      6b77914c
  21. 27 Jun, 2017 1 commit
  22. 05 Jun, 2017 1 commit
    • Alan Zimmerman's avatar
      Udate hsSyn AST to use Trees that Grow · 8e6ec0fa
      Alan Zimmerman authored
      Summary:
      See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow
      
      This commit prepares the ground for a full extensible AST, by replacing the type
      parameter for the hsSyn data types with a set of indices into type families,
      
          data GhcPs -- ^ Index for GHC parser output
          data GhcRn -- ^ Index for GHC renamer output
          data GhcTc -- ^ Index for GHC typechecker output
      
      These are now used instead of `RdrName`, `Name` and `Id`/`TcId`/`Var`
      
      Where the original name type is required in a polymorphic context, this is
      accessible via the IdP type family, defined as
      
          type family IdP p
          type instance IdP GhcPs = RdrName
          type instance IdP GhcRn = Name
          type instance IdP GhcTc = Id
      
      These types are declared in the new 'hsSyn/HsExtension.hs' module.
      
      To gain a better understanding of the extension mechanism, it has been applied
      to `HsLit` only, also replacing the `SourceText` fields in them with extension
      types.
      
      To preserve extension generality, a type class is introduced to capture the
      `SourceText` interface, which must be honoured by all of the extension points
      which originally had a `SourceText`.  The class is defined as
      
          class HasSourceText a where
            -- Provide setters to mimic existing constructors
            noSourceText  :: a
            sourceText    :: String -> a
      
            setSourceText :: SourceText -> a
            getSourceText :: a -> SourceText
      
      And the constraint is captured in `SourceTextX`, which is a constraint type
      listing all the extension points that make use of the class.
      
      Updating Haddock submodule to match.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, shayan-najd, goldfire, austin, bgamari
      
      Subscribers: rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3609
      8e6ec0fa
  23. 02 Jun, 2017 1 commit
    • Ryan Scott's avatar
      Use lengthIs and friends in more places · a786b136
      Ryan Scott authored
      While investigating #12545, I discovered several places in the code
      that performed length-checks like so:
      
      ```
      length ts == 4
      ```
      
      This is not ideal, since the length of `ts` could be much longer than 4,
      and we'd be doing way more work than necessary! There are already a slew
      of helper functions in `Util` such as `lengthIs` that are designed to do
      this efficiently, so I found every place where they ought to be used and
      did just that. I also defined a couple more utility functions for list
      length that were common patterns (e.g., `ltLength`).
      
      Test Plan: ./validate
      
      Reviewers: austin, hvr, goldfire, bgamari, simonmar
      
      Reviewed By: bgamari, simonmar
      
      Subscribers: goldfire, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3622
      a786b136
  24. 12 May, 2017 1 commit
    • Ben Gamari's avatar
      Revert "Treat banged bindings as FunBinds" · 3032ae81
      Ben Gamari authored
      This partially reverts commit 37299536 as it
      doesn't actually fix #13594. Namely it does not revert the mkPrefixFunRhs
      refactoring since this is rather independent from the functional changes.
      
      Going to try again with a whole working patch
      3032ae81
  25. 11 May, 2017 1 commit
    • Ben Gamari's avatar
      pmCheck: Don't generate PmId OccNames from Uniques · 6f999230
      Ben Gamari authored
      Doug Wilson astutely noticed that the pattern match checker was spending
      a significant amount of time in mkPmId. It turns out that it was
      producing Ids with OccNames that were generated from a Unique, which are
      non-trivial to render. Since Var is strict in Name, Name in OccName, and
      OccName in its FastString all of this encoding work was being done
      despite the fact that it was (as far as I can tell) never actually
      needed.
      
      Test Plan: Validate, note allocations of `T11195`
      
      Reviewers: austin, gkaracha
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3568
      6f999230
  26. 09 May, 2017 1 commit
    • Ben Gamari's avatar
      Treat banged bindings as FunBinds · 37299536
      Ben Gamari authored
      This reworks the HsSyn representation to make banged variable patterns
      (e.g. !x = e) be represented as FunBinds instead of PatBinds, adding a flag to
      FunRhs to record the bang.
      
      Fixes #13594.
      
      Reviewers: austin, goldfire, alanz, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3525
      37299536
  27. 08 May, 2017 1 commit
  28. 03 May, 2017 1 commit
  29. 11 Apr, 2017 1 commit
  30. 06 Mar, 2017 1 commit
    • Ben Gamari's avatar
      Read COMPLETE sets from external packages · 8ca4bb1c
      Ben Gamari authored
      Currently, `COMPLETE` pragmas are not read from external packages at
      all, which quite limits their usefulness. This extends
      `ExternalPackageState` to include `COMPLETE` sets from other packages,
      and plumbs around the appropriate values to make it work the way you'd
      expect it to.
      
      Requires a `binary` submodule update.
      
      Fixes #13350.
      
      Test Plan: make test TEST=T13350
      
      Reviewers: rwbarton, mpickering, austin, simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3257
      8ca4bb1c
  31. 03 Mar, 2017 2 commits
  32. 08 Feb, 2017 1 commit
    • Simon Peyton Jones's avatar
      Kill inaccessible-branch complaints in record update · 3cfef763
      Simon Peyton Jones authored
      Trac #12957 (the original case in the Description) showed a record
      update that yielded an "inaccessible code" warning. This should not
      happen; it's just some redundant code generated by the desugarer (later
      pruned away) and it's not the user's fault.
      
      This patch suppresses the warning.  See Check.hs
      Note [Inaccessible warnings for record updates]
      3cfef763
  33. 06 Feb, 2017 2 commits
    • Gabor Greif's avatar
      Typos in comments [skip ci] · 4aae1918
      Gabor Greif authored
      4aae1918
    • Matthew Pickering's avatar
      Don't return empty initial uncovered set for an unsat context · adb565aa
      Matthew Pickering authored
      Previously when the checker encountered an unsatisfiable term of type
      context it would return an empty initial uncovered set. This caused all
      pattern matches in the context to be reported as redudant.
      
      This is arguably correct behaviour as they will never be reached but it
      is better to recover and provide accurate warnings for these cases to
      avoid error cascades. It would perhaps be better to report an error to
      the user about an inacessible branch but this is certainly better than
      many confusing redundant match warnings.
      
      Reviewers: gkaracha, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3064
      adb565aa
  34. 02 Feb, 2017 1 commit