1. 04 Dec, 2015 17 commits
    • Simon Peyton Jones's avatar
      Fix egregious error in eta-reduction of data families · 1160dc51
      Simon Peyton Jones authored
      This terrible and long-standing bug was shown up by Trac #11148.
      We are trying to eta-reduce a data family instance, so that we
      can then derive Functor or Generic.  But we were assuming, for
      absolutely not reason whatsoever, that the type variables were
      lined up in a convenient order.  The fact that it ever worked
      was a fluke.
      
      This patch fixes it properly.  Main change is in eta_reduce
      in TcInstDcls.tcDataFamInstDecl
      1160dc51
    • Simon Peyton Jones's avatar
      Make -dppr-debug show contents of (TypeError ...) · 822141b9
      Simon Peyton Jones authored
      Just for debugging
      822141b9
    • Simon Peyton Jones's avatar
      Wibbles only · 1cb3c8c2
      Simon Peyton Jones authored
      1cb3c8c2
    • Simon Peyton Jones's avatar
      Add derived constraints for wildcard signatures · 28035c09
      Simon Peyton Jones authored
      This fixes Trac #11016
      
      See Note [Add deriveds for signature contexts] in TcSimplify]
      28035c09
    • Simon Peyton Jones's avatar
      Case-of-empty-alts is trivial (Trac #11155) · 1c9fd3f1
      Simon Peyton Jones authored
      As you'll see from Trac #11155, the code generator was confused
      by a binding let x = y in ....   Why did that happen? Because of
      a (case y of {}) expression on the RHS.
      
      The right thing is just to expand what a "trivial" expression is.
      
      See Note [Empty case is trivial] in CoreUtils.
      1c9fd3f1
    • Bartosz Nitka's avatar
      Make callToPats deterministic in SpecConstr · 5b2b7e33
      Bartosz Nitka authored
      This fixes a non-determinism bug where where depending on the
      order of uniques allocated, the specialized workers would have different
      order of arguments.
      
      Compare:
      
      ```
        $s$wgo_s1CN :: Int# -> Int -> Int#
        [LclId, Arity=2, Str=DmdType <L,U><L,U>]
        $s$wgo_s1CN =
          \ (sc_s1CI :: Int#) (sc_s1CJ :: Int) ->
            case tagToEnum# @ Bool (<=# sc_s1CI 0#) of _ [Occ=Dead] {
              False ->
                $wgo_s1BU (Just @ Int (I# (-# sc_s1CI 1#))) (Just @ Int sc_s1CJ);
              True -> 0#
            }
      ```
      
      vs
      
      ```
        $s$wgo_s18mTj :: Int -> Int# -> Int#
        [LclId, Arity=2, Str=DmdType <L,U><L,U>]
        $s$wgo_s18mTj =
          \ (sc_s18mTn :: Int) (sc_s18mTo :: Int#) ->
            case tagToEnum# @ Bool (<=# sc_s18mTo 0#) of _ [Occ=Dead] {
              False ->
                $wgo_s18mUc
                  (Just @ Int (I# (-# sc_s18mTo 1#))) (Just @ Int sc_s18mTn);
              True -> 0#
            }
      ```
      
      Test Plan:
      I've added a new testcase
      ./validate
      
      Reviewers: simonmar, simonpj, austin, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1508
      
      GHC Trac Issues: #4012
      5b2b7e33
    • Ben Gamari's avatar
      T5642: Skip it entirely · 96e67c01
      Ben Gamari authored
      It uses so much memory that it would be unsafe to even allow it to run
      as it may jeopardize the stability of the build-bots.
      96e67c01
    • Ben Gamari's avatar
      T5642 is broken · dc33e4c6
      Ben Gamari authored
      This appears to be due to the new exhaustiveness checker. See #11163.
      dc33e4c6
    • Ben Gamari's avatar
      Bump allocations for T783 · e9220daf
      Ben Gamari authored
      The new pattern match checker increased allocations by over 100%.
      Tracking in #11162.
      e9220daf
    • Ben Gamari's avatar
      Check: More Clang/CPP wibbles · befc4e4c
      Ben Gamari authored
      befc4e4c
    • Herbert Valerio Riedel's avatar
      Use builtin ISO 8859-1 decoder in mkTextEncoding · 36a208f4
      Herbert Valerio Riedel authored
      We already do this for UTF8/16/32, so it seems obvious do the same
      for the closely related popular ISO 8859-1 encoding, and avoid iconv
      issues on some platforms (such as AIX which which bundles a broken
      `libiconv` by default)
      
      This fixes #11096
      36a208f4
    • Ben Gamari's avatar
      PmExpr: Fix CPP unacceptable too clang's CPP · d40f5b78
      Ben Gamari authored
      d40f5b78
    • Herbert Valerio Riedel's avatar
      On AIX we need -D_BSD defined in <Stg.h> · 6ef351df
      Herbert Valerio Riedel authored
      As otherwise <math.h> includes <stdlib.h> which breaks compilation
      of .hc files
      6ef351df
    • Herbert Valerio Riedel's avatar
      RTS: Rename InCall.stat struct field to .rstat · cd9f3bf9
      Herbert Valerio Riedel authored
      On AIX, C system headers can redirect the token `stat` via
      
          #define stat stat64
      
      to provide large-file support. Simply avoiding the use of `stat` as an
      identifier eschews macro-replacement.
      
      Differential Revision: https://phabricator.haskell.org/D1566
      cd9f3bf9
    • Herbert Valerio Riedel's avatar
      Use Autoconf's AC_USE_SYSTEM_EXTENSIONS · 7af29da0
      Herbert Valerio Riedel authored
      This takes care of setting feature test macros (i.e. let Autoconf decide when
      those can be set safely) to allow subsequent Autoconf tests to better detect
      available OS features.
      
      This also includes a submodule update of unix which enables the use of
      `AC_USE_SYSTEM_EXTENSIONS` in there as well.
      
      Specifically, this takes care of setting `_GNU_SOURCE` (which allows to remove
      two occurences where it's set manually) and `_ALL_SOURCE` (which fixes issues
      on AIX).
      
      See also
      
        https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Posix-Variants.html
      
      for details.
      
      At some point we may want to reconsider the purpose of "rts/PosixSource.h" and
      rely more on Autoconf instead.
      7af29da0
    • Georgios Karachalias's avatar
      99d01e1d
    • Georgios Karachalias's avatar
      Improve performance for PM check on literals (Fixes #11160 and #11161) · ae4398d6
      Georgios Karachalias authored
      Two changes:
      
      1. Instead of generating constraints of the form (x ~ e) (as we do in
      the paper), generate constraints of the form (e ~ e). The term oracle
      (`tmOracle` in deSugar/TmOracle.hs) is not really efficient and in the
      presence of many (x ~ e) constraints behaves quadratically. For
      literals, constraints of the form (False ~ (x ~ lit)) are pretty common,
      so if we start with { y ~ False, y ~ (x ~ lit) } we end up givng to the
      solver (a) twice as many constraints as we need and (b) half of them
      trigger the solver's weakness. This fixes #11160.
      
      2. Treat two overloaded literals that look different as different. This
      is not entirely correct but it is what both the previous and the current
      check did. I had the ambitious plan to do the *right thing* (equality
      between overloaded literals is undecidable in the general case) and just
      use this assumption when issuing the warnings. It seems to generate much
      more constraints than I expected (breaks #11161) so I just do it
      immediately now instead of generating everything and filtering
      afterwards.
      
      Even if it is not (strictly speaking) correct, we have the following:
        * Gives the "expected" warnings (the ones Ocaml or the previous
          algorithm would give) and,
        * Most importantly, it is safe. Unless a catch-all clause exists, a
          match against literals is always non-exhaustive. So, effectively
          this affects only what is shown to the user (and, evidently,
          performance!).
      ae4398d6
  2. 03 Dec, 2015 9 commits
    • Ben Gamari's avatar
      Bump hoopl submodule · 40fc3536
      Ben Gamari authored
      To fix redundant patterns.
      40fc3536
    • Ben Gamari's avatar
      Update test output · 934b3a06
      Ben Gamari authored
      934b3a06
    • Ben Gamari's avatar
      Kill redundant patterns · 0dd61fe7
      Ben Gamari authored
      George's new exhaustiveness checker now realizes these are impossible.
      Yay!
      0dd61fe7
    • Ben Gamari's avatar
      Fix haddock syntax · 7b29b0b1
      Ben Gamari authored
      Sadly we can't annotate the elements of a tuple
      7b29b0b1
    • Ben Gamari's avatar
      Revert "Create empty dump files when there was nothing to dump" · c5597bb6
      Ben Gamari authored
      This reverts commit 8cba907a which
      broke `-ddump-to-file`.
      c5597bb6
    • Sergei Trofimovich's avatar
      extending_ghc.rst: fix broken link (Trac #10950) · a034031a
      Sergei Trofimovich authored
      
      
      The error exibits as build failures
      of two types:
      
        1. extending_ghc.rst:: ERROR:
            Anonymous hyperlink mismatch:
              1 references but 0 targets.
            See "backrefs" attribute for IDs.
      
        2. reading sources... [ 33%] glasgow_exts
             Exception occurred:
                pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)
             RecursionError: maximum recursion depth exceeded
             while pickling an object
      
      Broken link created circular reference and failed to
      serialize the result.
      
      Fixed the problem by pointing to relevant section.
      Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>
      a034031a
    • Ben Gamari's avatar
      43a31fe4
    • Georgios Karachalias's avatar
      Major Overhaul of Pattern Match Checking (Fixes #595) · 8a506104
      Georgios Karachalias authored
      This patch adresses several problems concerned with exhaustiveness and
      redundancy checking of pattern matching. The list of improvements includes:
      
      * Making the check type-aware (handles GADTs, Type Families, DataKinds, etc.).
        This fixes #4139, #3927, #8970 and other related tickets.
      
      * Making the check laziness-aware. Cases that are overlapped but affect
        evaluation are issued now with "Patterns have inaccessible right hand side".
        Additionally, "Patterns are overlapped" is now replaced by "Patterns are
        redundant".
      
      * Improved messages for literals. This addresses tickets #5724, #2204, etc.
      
      * Improved reasoning concerning cases where simple and overloaded
        patterns are matched (See #322).
      
      * Substantially improved reasoning for pattern guards. Addresses #3078.
      
      * OverloadedLists extension does not break exhaustiveness checking anymore
        (addresses #9951). Note that in general this cannot be handled but if we know
        that an argument has type '[a]', we treat it as a list since, the instance of
        'IsList' gives the identity for both 'fromList' and 'toList'. If the type is
        not clear or is not the list type, then the check cannot do much still. I am
        a bit concerned about OverlappingInstances though, since one may override the
        '[a]' instance with e.g. an '[Int]' instance that is not the identity.
      
      * Improved reasoning for nested pattern matching (partial solution). Now we
        propagate type and (some) term constraints deeper when checking, so we can
        detect more inconsistencies. For example, this is needed for #4139.
      
      I am still not satisfied with several things but I would like to address at
      least the following before the next release:
          Term constraints are too many and not printed for non-exhaustive matches
      (with the exception of literals). This sometimes results in two identical (in
      appearance) uncovered warnings. Unless we actually show their difference, I
      would like to have a single warning.
      8a506104
    • Sergei Trofimovich's avatar
      users_guide/glasgow_exts.rst: fix link markup · d25f3c07
      Sergei Trofimovich authored
      
      
      sphinx-1.3.1 found errors as:
        users_guide/glasgow_exts.rst:1799:
          WARNING: malformed hyperlink target.
        users_guide/glasgow_exts.rst:10638:
          WARNING: Inline interpreted text or phrase
          reference start-string without end-string.
      Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>
      d25f3c07
  3. 02 Dec, 2015 12 commits
  4. 01 Dec, 2015 2 commits
    • Simon Peyton Jones's avatar
      Refactor treatment of wildcards · 1e041b73
      Simon Peyton Jones authored
      This patch began as a modest refactoring of HsType and friends, to
      clarify and tidy up exactly where quantification takes place in types.
      Although initially driven by making the implementation of wildcards more
      tidy (and fixing a number of bugs), I gradually got drawn into a pretty
      big process, which I've been doing on and off for quite a long time.
      
      There is one compiler performance regression as a result of all
      this, in perf/compiler/T3064.  I still need to look into that.
      
      * The principal driving change is described in Note [HsType binders]
        in HsType.  Well worth reading!
      
      * Those data type changes drive almost everything else.  In particular
        we now statically know where
      
             (a) implicit quantification only (LHsSigType),
                 e.g. in instance declaratios and SPECIALISE signatures
      
             (b) implicit quantification and wildcards (LHsSigWcType)
                 can appear, e.g. in function type signatures
      
      * As part of this change, HsForAllTy is (a) simplified (no wildcards)
        and (b) split into HsForAllTy and HsQualTy.  The two contructors
        appear when and only when the correponding user-level construct
        appears.  Again see Note [HsType binders].
      
        HsExplicitFlag disappears altogether.
      
      * Other simplifications
      
           - ExprWithTySig no longer needs an ExprWithTySigOut variant
      
           - TypeSig no longer needs a PostRn name [name] field
             for wildcards
      
           - PatSynSig records a LHsSigType rather than the decomposed
             pieces
      
           - The mysterious 'GenericSig' is now 'ClassOpSig'
      
      * Renamed LHsTyVarBndrs to LHsQTyVars
      
      * There are some uninteresting knock-on changes in Haddock,
        because of the HsSyn changes
      
      I also did a bunch of loosely-related changes:
      
      * We already had type synonyms CoercionN/CoercionR for nominal and
        representational coercions.  I've added similar treatment for
      
            TcCoercionN/TcCoercionR
      
            mkWpCastN/mkWpCastN
      
        All just type synonyms but jolly useful.
      
      * I record-ised ForeignImport and ForeignExport
      
      * I improved the (poor) fix to Trac #10896, by making
        TcTyClsDecls.checkValidTyCl recover from errors, but adding a
        harmless, abstract TyCon to the envt if so.
      
      * I did some significant refactoring in RnEnv.lookupSubBndrOcc,
        for reasons that I have (embarrassingly) now totally forgotten.
        It had to do with something to do with import and export
      
      Updates haddock submodule.
      1e041b73
    • Bartosz Nitka's avatar
      Make the determinism tests more robust · b432e2f3
      Bartosz Nitka authored
      The tests weren't explicit enough about comparing under different
      unique allocation strategies. This led to some confusion on my part when
      I started overriding flags in `testsuite/mk/test.mk`.
      Includes a `.gitignore` rule.
      
      Test Plan: harbormaster
      
      Reviewers: austin, simonmar, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1555
      b432e2f3