Skip to content
Snippets Groups Projects
  1. Sep 13, 2022
    • sheaf's avatar
      Diagnostic codes: acccept test changes · 362cca13
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The testsuite output now contains diagnostic codes, so many tests need
      to be updated at once.
      We decided it was best to keep the diagnostic codes in the testsuite
      output, so that contributors don't inadvertently make changes to the
      diagnostic codes.
      362cca13
  2. Aug 19, 2022
  3. Apr 01, 2022
  4. Oct 09, 2021
    • sheaf's avatar
      Reject GADT pattern matches in arrow notation · 31983ab4
      sheaf authored and Marge Bot's avatar Marge Bot committed
        Tickets #20469 and #20470 showed that the current
        implementation of arrows is not at all up to the task
        of supporting GADTs: GHC produces ill-scoped Core programs
        because it doesn't propagate the evidence introduced by a GADT
        pattern match.
      
        For the time being, we reject GADT pattern matches in arrow notation.
        Hopefully we are able to add proper support for GADTs in arrows
        in the future.
      31983ab4
  5. May 24, 2021
  6. Feb 14, 2021
  7. Jan 22, 2021
    • Sylvain Henry's avatar
      Arrows: collect evidence binders · 01ea56a2
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Evidence binders were not collected by
      GHC.HsToCore.Arrows.collectStmtBinders, hence bindings for dictionaries
      were not taken into account while computing local variables in
      statements. As a consequence we had a transformation similar to this:
      
          data Point a where Point :: RealFloat a => a -> Point a
      
          do
              p -< ...
              returnA -< ... (Point 0)
      
      ===> { Type-checking }
      
          do
              let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
              p -< ...
              returnA -< ... (Point $dRealFloat_xyz 0)
      
      ===> { Arrows HsToCore }
      
          first ...
          >>> arr (\(p, ()) -> case p of ... ->
                  let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
                  in case .. of () -> ())
          >>> \((),()) -> ... (Point $dRealFloat_xyz 0) -- dictionary not in scope
      
      Now evidences are passed in the environment if necessary and we get:
      
      ===> { Arrows HsToCore }
      
          first ...
          >>> arr (\(p, ()) -> case p of ... ->
                  let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
                  in case .. of () -> $dRealFloat_xyz)
          >>> \(ds,()) ->
                  let $dRealFloat_xyz = ds
                  in ... (Point $dRealFloat_xyz 0) -- dictionary in scope
      
      Note that collectStmtBinders has been copy-pasted from GHC.Hs.Utils.
      This ought to be factorized but Note [Dictionary binders in ConPatOut]
      claims that:
      
          Do *not* gather (a) dictionary and (b) dictionary bindings as
          binders of a ConPatOut pattern.  For most calls it doesn't matter,
          because it's pre-typechecker and there are no ConPatOuts.  But it
          does matter more in the desugarer; for example,
          GHC.HsToCore.Utils.mkSelectorBinds uses collectPatBinders.  In a
          lazy pattern, for example f ~(C x y) = ..., we want to generate
          bindings for x,y but not for dictionaries bound by C.  (The type
          checker ensures they would not be used.)
      
          Desugaring of arrow case expressions needs these bindings (see
          GHC.HsToCore.Arrows and arrowcase1), but SPJ (Jan 2007) says it's
          safer for it to use its own pat-binder-collector:
      
      Accordingly to the last sentence, this patch doesn't make any attempt at
      factorizing both codes.
      
      Fix #18950
      01ea56a2
  8. Dec 12, 2020
    • Sylvain Henry's avatar
      Arrows: correctly query arrow methods (#17423) · f9f9f030
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Consider the following code:
      
          proc (C x y) -> ...
      
      Before this patch, the evidence binding for the Arrow dictionary was
      attached to the C pattern:
      
          proc (C x y) { $dArrow = ... } -> ...
      
      But then when we desugar this, we use arrow operations ("arr", ">>>"...)
      specialised for this arrow:
      
          let
              arr_xy = arr $dArrow -- <-- Not in scope!
              ...
          in
              arr_xy (\(C x y) { $dArrow = ... } -> ...)
      
      This patch allows arrow operations to be type-checked before the proc
      itself, avoiding this issue.
      
      Fix #17423
      f9f9f030
  9. Jun 05, 2020
    • Simon Peyton Jones's avatar
      Simple subsumption · 2b792fac
      Simon Peyton Jones authored
      This patch simplifies GHC to use simple subsumption.
        Ticket #17775
      
      Implements GHC proposal #287
         https://github.com/ghc-proposals/ghc-proposals/blob/master/
         proposals/0287-simplify-subsumption.rst
      
      All the motivation is described there; I will not repeat it here.
      The implementation payload:
       * tcSubType and friends become noticably simpler, because it no
         longer uses eta-expansion when checking subsumption.
       * No deeplyInstantiate or deeplySkolemise
      
      That in turn means that some tests fail, by design; they can all
      be fixed by eta expansion.  There is a list of such changes below.
      
      Implementing the patch led me into a variety of sticky corners, so
      the patch includes several othe changes, some quite significant:
      
      * I made String wired-in, so that
          "foo" :: String   rather than
          "foo" :: [Char]
        This improves error messages, and fixes #15679
      
      * The pattern match checker relies on knowing about in-scope equality
        constraints, andd adds them to the desugarer's environment using
        addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
        simple-subsumption ends up with dictionaries there. So I added a
        call to addTyCsDs.  This is really part of #18049.
      
      * I moved the ic_telescope field out of Implication and into
        ForAllSkol instead.  This is a nice win; just expresses the code
        much better.
      
      * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
        We called checkDataKindSig inside tc_kind_sig, /before/
        solveEqualities and zonking.  Obviously wrong, easily fixed.
      
      * solveLocalEqualitiesX: there was a whole mess in here, around
        failing fast enough.  I discovered a bad latent bug where we
        could successfully kind-check a type signature, and use it,
        but have unsolved constraints that could fill in coercion
        holes in that signature --  aargh.
      
        It's all explained in Note [Failure in local type signatures]
        in GHC.Tc.Solver. Much better now.
      
      * I fixed a serious bug in anonymous type holes. IN
          f :: Int -> (forall a. a -> _) -> Int
        that "_" should be a unification variable at the /outer/
        level; it cannot be instantiated to 'a'.  This was plain
        wrong.  New fields mode_lvl and mode_holes in TcTyMode,
        and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.
      
        This fixes #16292, but makes no progress towards the more
        ambitious #16082
      
      * I got sucked into an enormous refactoring of the reporting of
        equality errors in GHC.Tc.Errors, especially in
            mkEqErr1
            mkTyVarEqErr
            misMatchMsg
            misMatchMsgOrCND
        In particular, the very tricky mkExpectedActualMsg function
        is gone.
      
        It took me a full day.  But the result is far easier to understand.
        (Still not easy!)  This led to various minor improvements in error
        output, and an enormous number of test-case error wibbles.
      
        One particular point: for occurs-check errors I now just say
           Can't match 'a' against '[a]'
        rather than using the intimidating language of "occurs check".
      
      * Pretty-printing AbsBinds
      
      Tests review
      
      * Eta expansions
         T11305: one eta expansion
         T12082: one eta expansion (undefined)
         T13585a: one eta expansion
         T3102:  one eta expansion
         T3692:  two eta expansions (tricky)
         T2239:  two eta expansions
         T16473: one eta
         determ004: two eta expansions (undefined)
         annfail06: two eta (undefined)
         T17923: four eta expansions (a strange program indeed!)
         tcrun035: one eta expansion
      
      * Ambiguity check at higher rank.  Now that we have simple
        subsumption, a type like
           f :: (forall a. Eq a => Int) -> Int
        is no longer ambiguous, because we could write
           g :: (forall a. Eq a => Int) -> Int
           g = f
        and it'd typecheck just fine.  But f's type is a bit
        suspicious, and we might want to consider making the
        ambiguity check do a check on each sub-term.  Meanwhile,
        these tests are accepted, whereas they were previously
        rejected as ambiguous:
           T7220a
           T15438
           T10503
           T9222
      
      * Some more interesting error message wibbles
         T13381: Fine: one error (Int ~ Exp Int)
                 rather than two (Int ~ Exp Int, Exp Int ~ Int)
         T9834:  Small change in error (improvement)
         T10619: Improved
         T2414:  Small change, due to order of unification, fine
         T2534:  A very simple case in which a change of unification order
                 means we get tow unsolved constraints instead of one
         tc211: bizarre impredicative tests; just accept this for now
      
      Updates Cabal and haddock submodules.
      
      Metric Increase:
        T12150
        T12234
        T5837
        haddock.base
      Metric Decrease:
        haddock.compiler
        haddock.Cabal
        haddock.base
      
      Merge note: This appears to break the
      `UnliftedNewtypesDifficultUnification` test. It has been marked as
      broken in the interest of merging.
      
      (cherry picked from commit 66b7b195)
      2b792fac
  10. Apr 30, 2020
  11. Nov 24, 2019
  12. Mar 15, 2019
  13. Dec 13, 2018
    • Ben Gamari's avatar
      testsuite: Normalise away spurious differences in out-of-scope instances · 9d9f4c9a
      Ben Gamari authored
      This fixes a variety of testsuite failures with integer-simple of the form
      
      ```
      --- typecheck/should_fail/tcfail072.run/tcfail072.stderr.normalised
      +++ typecheck/should_fail/tcfail072.run/tcfail072.comp.stderr.normalised
      @@ -12,7 +12,7 @@
                 -- Defined in ‘integer-<IMPL>-<VERSION>:GHC.Integer.Type’
               instance Ord () -- Defined in ‘GHC.Classes’
               ...plus 21 others
      -        ...plus three instances involving out-of-scope types
      +        ...plus two instances involving out-of-scope types
               (use -fprint-potential-instances to see them all)
            In the expression: g A
             In an equation for ‘g’: g (B _ _) = g A
      ```
      
      In service of fixing #16043.
      9d9f4c9a
  14. Dec 07, 2016
    • Alan Zimmerman's avatar
      Add HsSyn prettyprinter tests · 499e4382
      Alan Zimmerman authored
      Summary:
      Add prettyprinter tests, which take a file, parse it, pretty print it,
      re-parse the pretty printed version and then compare the original and
      new ASTs (ignoring locations)
      
      Updates haddock submodule to match the AST changes.
      
      There are three issues outstanding
      
      1. Extra parens around a context are not reproduced. This will require an
         AST change and will be done in a separate patch.
      
      2. Currently if an `HsTickPragma` is found, this is not pretty-printed,
         to prevent noise in the output.
      
         I am not sure what the desired behaviour in this case is, so have left
         it as before. Test Ppr047 is marked as expected fail for this.
      
      3. Apart from in a context, the ParsedSource AST keeps all the parens from
         the original source.  Something is happening in the renamer to remove the
         parens around visible type application, causing T12530 to fail, as the
         dumped splice decl is after the renamer.
      
         This needs to be fixed by keeping the parens, but I do not know where they
         are being removed.  I have amended the test to pass, by removing the parens
         in the expected output.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, mpickering, simonpj, bgamari, austin
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: simonpj, goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2752
      
      GHC Trac Issues: #3384
      499e4382
  15. Jun 20, 2016
  16. Jun 13, 2016
    • Simon Peyton Jones's avatar
      Improve typechecking of let-bindings · 15b9bf4b
      Simon Peyton Jones authored
      This major commit was initially triggered by #11339, but it spiraled
      into a major review of the way in which type signatures for bindings
      are handled, especially partial type signatures.  On the way I fixed a
      number of other bugs, namely
         #12069
         #12033
         #11700
         #11339
         #11670
      
      The main change is that I completely reorganised the way in which type
      signatures in bindings are handled. The new story is in TcSigs
      Note [Overview of type signatures].  Some specific:
      
      * Changes in the data types for signatures in TcRnTypes:
        TcIdSigInfo and new TcIdSigInst
      
      * New module TcSigs deals with typechecking type signatures
        and pragmas. It contains code mostly moved from TcBinds,
        which is already too big
      
      * HsTypes: I swapped the nesting of HsWildCardBndrs
        and HsImplicitBndsrs, so that the wildcards are on the
        oustide not the insidde in a LHsSigWcType.  This is just
        a matter of convenient, nothing deep.
      
      There are a host of other changes as knock-on effects, and
      it all took FAR longer than I anticipated :-).  But it is
      a significant improvement, I think.
      
      Lots of error messages changed slightly, some just variants but
      some modest improvements.
      
      New tests
      
      * typecheck/should_compile
          * SigTyVars: a scoped-tyvar test
          * ExPat, ExPatFail: existential pattern bindings
          * T12069
          * T11700
          * T11339
      
      * partial-sigs/should_compile
          * T12033
          * T11339a
          * T11670
      
      One thing to check:
      
      * Small change to output from ghc-api/landmines.
        Need to check with Alan Zimmerman
      15b9bf4b
  17. Mar 24, 2016
    • Josh Price's avatar
      Add unicode syntax for banana brackets · 03a1bb4d
      Josh Price authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      Add "⦇" and "⦈" as unicode alternatives for "(|" and "|)" respectively.
      
      This must be implemented differently than other unicode additions
      because ⦇" and "⦈" are interpretted as a $unigraphic rather than
      a $unisymbol.
      
      Test Plan: validate
      
      Reviewers: goldfire, bgamari, austin
      
      Reviewed By: bgamari, austin
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2012
      
      GHC Trac Issues: #10162
      03a1bb4d
  18. Feb 23, 2016
  19. Dec 24, 2015
    • Richard Eisenberg's avatar
      Visible type application · 2db18b81
      Richard Eisenberg authored
      This re-working of the typechecker algorithm is based on
      the paper "Visible type application", by Richard Eisenberg,
      Stephanie Weirich, and Hamidhasan Ahmed, to be published at
      ESOP'16.
      
      This patch introduces -XTypeApplications, which allows users
      to say, for example `id @Int`, which has type `Int -> Int`. See
      the changes to the user manual for details.
      
      This patch addresses tickets #10619, #5296, #10589.
      2db18b81
  20. Dec 01, 2015
    • 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
  21. Nov 24, 2015
    • elaforge's avatar
      Rearrange error msgs and add section markers (Trac #11014). · c05fddde
      elaforge authored and Ben Gamari's avatar Ben Gamari committed
      This puts the "Relevant bindings" section at the end.
      
      It uses a TcErrors.Report Monoid to divide messages by importance and
      then mappends them together.  This is not the most efficient way since
      there are various intermediate Reports and list appends, but it probably
      doesn't matter since error messages shouldn't get that large, and are
      usually prepended.  In practice, everything is `important` except
      `relevantBindings`, which is `supplementary`.
      
      ErrMsg's errMsgShortDoc and errMsgExtraInfo were extracted into ErrDoc,
      which has important, context, and suppelementary fields.  Each of those
      three sections is marked with a bullet character, '•' on unicode
      terminals and '*' on ascii terminals.  Since this breaks tons of tests,
      I also modified testlib.normalise_errmsg to strip out '•'s.
      
      --- Additional notes:
      
      To avoid prepending * to an empty doc, I needed to filter empty docs.
      This seemed less error-prone than trying to modify everyone who produces
      SDoc to instead produce Maybe SDoc.  So I added `Outputable.isEmpty`.
      Unfortunately it needs a DynFlags, which is kind of bogus, but otherwise
      I think I'd need another Empty case for SDoc, and then it couldn't be a
      newtype any more.
      
      ErrMsg's errMsgShortString is only used by the Show instance, which is
      in turn only used by Show HscTypes.SourceError, which is in turn only
      needed for the Exception instance.  So it's probably possible to get rid
      of errMsgShortString, but that would a be an unrelated cleanup.
      
      Fixes #11014.
      
      Test Plan: see above
      
      Reviewers: austin, simonpj, thomie, bgamari
      
      Reviewed By: thomie, bgamari
      
      Subscribers: simonpj, nomeata, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1427
      
      GHC Trac Issues: #11014
      c05fddde
  22. Jul 30, 2015
  23. Jul 14, 2015
  24. Jul 13, 2015
  25. Jun 26, 2015
  26. Jan 06, 2015
    • Simon Peyton Jones's avatar
      Major patch to add -fwarn-redundant-constraints · 32973bf3
      Simon Peyton Jones authored
      The idea was promted by Trac #9939, but it was Christmas, so I did
      some recreational programming that went much further.
      
      The idea is to warn when a constraint in a user-supplied context is
      redundant.  Everything is described in detail in
        Note [Tracking redundant constraints]
      in TcSimplify.
      
      Main changes:
      
       * The new ic_status field in an implication, of type ImplicStatus.
         It replaces ic_insol, and includes information about redundant
         constraints.
      
       * New function TcSimplify.setImplicationStatus sets the ic_status.
      
       * TcSigInfo has sig_report_redundant field to say whenther a
         redundant constraint should be reported; and similarly
         the FunSigCtxt constructor of UserTypeCtxt
      
       * EvBinds has a field eb_is_given, to record whether it is a given
         or wanted binding. Some consequential chagnes to creating an evidence
         binding (so that we record whether it is given or wanted).
      
       * AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds;
         see Note [Typechecking plan for instance declarations] in
         TcInstDcls
      
       * Some significant changes to the type checking of instance
         declarations; Note [Typechecking plan for instance declarations]
         in TcInstDcls.
      
       * I found that TcErrors.relevantBindings was failing to zonk the
         origin of the constraint it was looking at, and hence failing to
         find some relevant bindings.  Easy to fix, and orthogonal to
         everything else, but hard to disentangle.
      
      Some minor refactorig:
      
       * TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds
      
       * TcClassDcl and TcInstDcls now have their own code for typechecking
         a method body, rather than sharing a single function. The shared
         function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code
         and the differences were growing confusing.
      
       * Add new function TcRnMonad.pushLevelAndCaptureConstraints, and
         use it
      
       * Add new function Bag.catBagMaybes, and use it in TcSimplify
      32973bf3
    • Simon Peyton Jones's avatar
      Modify a couple of error messages slightly · 00e1fc1b
      Simon Peyton Jones authored
      In particular
        In the type signature for:
           f :: Int -> Int
      I added the colon
      
      Also reword the "maybe you haven't applied a function to enough arguments?"
      suggestion to make grammatical sense.
      
      These tiny changes affect a lot of error messages.
      00e1fc1b
  27. Dec 17, 2014
    • Simon Peyton Jones's avatar
      Fix the scope-nesting for arrows · f50d62bb
      Simon Peyton Jones authored
      Previously we were capturing the *entire environment* when moving under
      a 'proc', for the newArrowScope/escapeArrowScope thing.  But that a blunderbuss,
      and in any case isn't right (the untouchable-type-varaible invariant gets
      invalidated).
      
      So I fixed it to be much more refined: just the LocalRdrEnv and constraints are
      captured.
      
      I think this is right; but if not we should just add more fields to ArrowCtxt,
      not return to the blunderbuss.
      
      This patch fixes the ASSERT failure in Trac #5267
      f50d62bb
  28. Feb 25, 2014
  29. Sep 10, 2013
    • Simon Peyton Jones's avatar
      Error message wibbles · 9ca4a73d
      Simon Peyton Jones authored
      Almost all are re-orderings of relevant-binding output
      
             Relevant bindings include
        +      m :: Map (a, b) elt (bound at T3169.hs:12:17)
        +      b :: b (bound at T3169.hs:12:13)
               lookup :: (a, b) -> Map (a, b) elt -> Maybe elt
                 (bound at T3169.hs:12:3)
        -      b :: b (bound at T3169.hs:12:13)
        -      m :: Map (a, b) elt (bound at T3169.hs:12:17)
      9ca4a73d
  30. Apr 29, 2013
    • Simon Peyton Jones's avatar
      Wibbles to error messages, following the fix for Trac #7851 · d5bd2d37
      Simon Peyton Jones authored
      In effect, the error context for naked variables now takes up
      a "slot" in the context stack; but it is often empty.  So the
      context stack becomes one shorter in those cases.  I don't think
      this matters; indeed, it's aguably an improvement.  Anyway that's
      why so many tests are affected.
      d5bd2d37
  31. Mar 04, 2013
  32. Feb 24, 2013
  33. Feb 11, 2013
  34. Nov 10, 2012
Loading