Skip to content
Snippets Groups Projects
  1. Aug 28, 2023
  2. Aug 23, 2023
    • sheaf's avatar
      Don't attempt pattern synonym error recovery · e7db36c1
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit gets rid of the pattern synonym error recovery mechanism
      (recoverPSB). The rationale is that the fake pattern synonym binding
      that the recovery mechanism introduced could lead to undesirable
      knock-on errors, and it isn't really feasible to conjure up a
      satisfactory binding as pattern synonyms can be used both in expressions
      and patterns.
      See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn.
      
      It isn't such a big deal to eagerly fail compilation on a pattern synonym
      that doesn't typecheck anyway.
      
      Fixes #23467
      e7db36c1
  3. Jul 05, 2023
    • Vladislav Zavialov's avatar
      testsuite: Do not require CUSKs · 679bbc97
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Numerous tests make use of CUSKs (complete user-supplied kinds),
      a legacy feature scheduled for deprecation. In order to proceed
      with the said deprecation, the tests have been updated to use SAKS
      instead (standalone kind signatures).
      
      This also allows us to remove the Haskell2010 language pragmas that
      were added in 115cd3c8 to work around the lack of CUSKs in GHC2021.
      679bbc97
  4. Jun 15, 2023
    • Sylvain Henry's avatar
      JS: more triage · 08d8e9ef
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      08d8e9ef
    • Andrei Borzenkov's avatar
      Report scoped kind variables at the type-checking phase (#16635) · 78cd1132
      Andrei Borzenkov authored
      This patch modifies the renamer to respect ScopedTypeVariables in kind
      signatures. This means that kind variables bound by the outermost
      `forall` now scope over the type:
      
        type F = '[Right @a @() () :: forall a. Either a ()]
        --         ^^^^^^^^^^^^^^^          ^^^
        --          in scope here        bound here
      
      However, any use of such variables is a type error, because we don't
      have type-level lambdas to bind them in Core. This is described in the
      new Note [Type variable scoping errors during type check] in GHC.Tc.Types.
      78cd1132
  5. Jun 13, 2023
  6. May 24, 2023
    • Hai Nguyen Quang's avatar
      Migrate errors in GHC.Tc.Validity · 838aaf4b
      Hai Nguyen Quang authored and Marge Bot's avatar Marge Bot committed
      This patch migrates the error messages in GHC.Tc.Validity to use
      the new diagnostic infrastructure.
      
      It adds the constructors:
      
        - TcRnSimplifiableConstraint
        - TcRnArityMismatch
        - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors
          and fundep coverage condition errors.
      838aaf4b
  7. May 05, 2023
  8. Apr 30, 2023
  9. Apr 01, 2023
  10. Mar 30, 2023
  11. Mar 29, 2023
    • sheaf's avatar
      Handle records in the renamer · 3f374399
      sheaf authored
      This patch moves the field-based logic for disambiguating record updates
      to the renamer. The type-directed logic, scheduled for removal, remains
      in the typechecker.
      
      To do this properly (and fix the myriad of bugs surrounding the treatment
      of duplicate record fields), we took the following main steps:
      
        1. Create GREInfo, a renamer-level equivalent to TyThing which stores
           information pertinent to the renamer.
           This allows us to uniformly treat imported and local Names in the
           renamer, as described in Note [GREInfo].
      
        2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
           distinguished between normal names and field names, we now store
           simple Names in GlobalRdrElt, along with the new GREInfo information
           which allows us to recover the FieldLabel for record fields.
      
        3. Add namespacing for record fields, within the OccNames themselves.
           This allows us to remove the mangling of duplicate field selectors.
      
           This change ensures we don't print mangled names to the user in
           error messages, and allows us to handle duplicate record fields
           in Template Haskell.
      
        4. Move record disambiguation to the renamer, and operate on the
           level of data constructors instead, to handle #21443.
      
           The error message text for ambiguous record updates has also been
           changed to reflect that type-directed disambiguation is on the way
           out.
      
      (3) means that OccEnv is now a bit more complex: we first key on the
      textual name, which gives an inner map keyed on NameSpace:
      
        OccEnv a ~ FastStringEnv (UniqFM NameSpace a)
      
      Note that this change, along with (2), both increase the memory residency
      of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
      regress somewhat in compile-time allocation.
      
      Even though (3) simplified a lot of code (in particular the treatment of
      field selectors within Template Haskell and in error messages), it came
      with one important wrinkle: in the situation of
      
        -- M.hs-boot
        module M where { data A; foo :: A -> Int }
        -- M.hs
        module M where { data A = MkA { foo :: Int } }
      
      we have that M.hs-boot exports a variable foo, which is supposed to match
      with the record field foo that M exports. To solve this issue, we add a
      new impedance-matching binding to M
      
        foo{var} = foo{fld}
      
      This mimics the logic that existed already for impedance-binding DFunIds,
      but getting it right was a bit tricky.
      See Note [Record field impedance matching] in GHC.Tc.Module.
      
      We also needed to be careful to avoid introducing space leaks in GHCi.
      So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
      ModIface. This means stubbing out all the GREInfo fields, with the
      function forceGlobalRdrEnv.
      When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
      This robustly avoids any space leaks caused by retaining old type
      environments.
      
      Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063
      
      Updates haddock submodule
      
      -------------------------
      Metric Increase:
          MultiComponentModules
          MultiLayerModules
          MultiLayerModulesDefsGhci
          MultiLayerModulesNoCode
          T13701
          T14697
          hard_hole_fits
      -------------------------
      3f374399
  12. Mar 23, 2023
  13. Mar 22, 2023
  14. Mar 06, 2023
  15. Mar 01, 2023
  16. Jan 28, 2023
    • Andrei Borzenkov's avatar
      Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) · 50b1e2e8
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind
      module. Instead, these TcRnMessage messages were introduced:
        TcRnMultipleFixityDecls
        TcRnIllegalPatternSynonymDecl
        TcRnIllegalClassBiding
        TcRnOrphanCompletePragma
        TcRnEmptyCase
        TcRnNonStdGuards
        TcRnDuplicateSigDecl
        TcRnMisplacedSigDecl
        TcRnUnexpectedDefaultSig
        TcRnBindInBootFile
        TcRnDuplicateMinimalSig
      50b1e2e8
  17. Nov 30, 2022
    • Simon Peyton Jones's avatar
      Use mkNakedFunTy in tcPatSynSig · a9d9b8c0
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      As #22521 showed, in tcPatSynSig we make a "fake type" to
      kind-generalise; and that type has unzonked type variables in it. So
      we must not use `mkFunTy` (which checks FunTy's invariants) via
      `mkPhiTy` when building this type.  Instead we need to use
      `mkNakedFunTy`.
      
      Easy fix.
      a9d9b8c0
  18. Nov 29, 2022
  19. Nov 25, 2022
    • Vladislav Zavialov's avatar
      Print unticked promoted data constructors (#20531) · 13d627bb
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      
      Before this patch, GHC unconditionally printed ticks before promoted
      data constructors:
      
      	ghci> type T = True  -- unticked (user-written)
      	ghci> :kind! T
      	T :: Bool
      	= 'True              -- ticked (compiler output)
      
      After this patch, GHC prints ticks only when necessary:
      
      	ghci> type F = False    -- unticked (user-written)
      	ghci> :kind! F
      	F :: Bool
      	= False                 -- unticked (compiler output)
      
      	ghci> data False        -- introduce ambiguity
      	ghci> :kind! F
      	F :: Bool
      	= 'False                -- ticked by necessity (compiler output)
      
      The old behavior can be enabled by -fprint-redundant-promotion-ticks.
      
      Summary of changes:
      * Rename PrintUnqualified to NamePprCtx
      * Add QueryPromotionTick to it
      * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
      * Introduce -fprint-redundant-promotion-ticks
      
      Co-authored-by: default avatarArtyom Kuznetsov <hi@wzrd.ht>
      13d627bb
  20. Oct 26, 2022
  21. 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
  22. Aug 19, 2022
  23. May 25, 2022
    • CarrieMY's avatar
      Desugar RecordUpd in `tcExpr` · e74fc066
      CarrieMY authored and sheaf's avatar sheaf committed
      This patch typechecks record updates by desugaring them inside
      the typechecker using the HsExpansion mechanism, and then typechecking
      this desugared result.
      
      Example:
      
          data T p q = T1 { x :: Int, y :: Bool, z :: Char }
                     | T2 { v :: Char }
                     | T3 { x :: Int }
                     | T4 { p :: Float, y :: Bool, x :: Int }
                     | T5
      
      The record update `e { x=e1, y=e2 }` desugars as follows
      
        e { x=e1, y=e2 }
          ===>
        let { x' = e1; y' = e2 } in
        case e of
           T1 _ _ z -> T1 x' y' z
           T4 p _ _ -> T4 p y' x'
      
      The desugared expression is put into an HsExpansion, and we typecheck
      that.
      
      The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr.
      
      Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289
      
      Updates haddock submodule
      e74fc066
  24. May 16, 2022
  25. May 11, 2022
  26. Apr 30, 2022
  27. Jan 29, 2022
    • Matthew Pickering's avatar
      Rework the handling of SkolemInfo · 268efcc9
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      
      The main purpose of this patch is to attach a SkolemInfo directly to
      each SkolemTv. This fixes the large number of bugs which have
      accumulated over the years where we failed to report errors due to
      having "no skolem info" for particular type variables. Now the origin of
      each type varible is stored on the type variable we can always report
      accurately where it cames from.
      
      Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946
        #19760 #20063 #13499 #14040
      
      The main changes of this patch are:
      
      * SkolemTv now contains a SkolemInfo field which tells us how the
        SkolemTv was created. Used when reporting errors.
      
      * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl)
        to the SkolemInfo and level of the type variables in ic_skols.
          * All ic_skols are TcTyVars -- Check is currently disabled
          * All ic_skols are SkolemTv
          * The tv_lvl of the ic_skols agrees with the ic_tclvl
          * The ic_info agrees with the SkolInfo of the implication.
      
        These invariants are checked by a debug compiler by
        checkImplicationInvariants.
      
      * Completely refactor kcCheckDeclHeader_sig which kept
        doing my head in. Plus, it wasn't right because it wasn't skolemising
        the binders as it decomposed the kind signature.
      
        The new story is described in Note [kcCheckDeclHeader_sig].  The code
        is considerably shorter than before (roughly 240 lines turns into 150
        lines).
      
        It still has the same awkward complexity around computing arity as
        before, but that is a language design issue.
        See Note [Arity inference in kcCheckDeclHeader_sig]
      
      * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used
        them to be clear which TcTyCons have "finished" kinds etc, and
        which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon]
      
      * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a
        better name, and it is very useful in kcCheckDeclHeader_sig, where
        eta-expansion isn't an issue.
      
      * Kill off the nasty `ClassScopedTvEnv` entirely.
      
      Co-authored-by: default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      268efcc9
  28. Jan 17, 2022
  29. Nov 23, 2021
    • Krzysztof Gogolewski's avatar
      Add a warning for GADT match + NoMonoLocalBinds (#20485) · 3ab3631f
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      Previously, it was an error to pattern match on a GADT
      without GADTs or TypeFamilies.
      This is now allowed. Instead, we check the flag MonoLocalBinds;
      if it is not enabled, we issue a warning, controlled by -Wgadt-mono-local-binds.
      
      Also fixes #20485: pattern synonyms are now checked too.
      3ab3631f
  30. Jul 12, 2021
    • Alfredo Di Napoli's avatar
      Add proper GHCHints for most PsMessage constructors · a181313e
      Alfredo Di Napoli authored
      This commit adds proper hints to most diagnostic types in the
      `GHC.Parser.Errors.Types` module. By "proper" we mean that previous to
      this commit the hints were bundled together with the diagnostic message,
      whereas now we moved most of them as proper `[GhcHint]` in the
      implementation of `diagnosticHints`.
      
      More specifically, this is the list of constructors which now has
      proper hints:
      
      * PsErrIllegalBangPattern
      * PsWarnOperatorWhitespaceExtConflict
      * PsErrLambdaCase
      * PsErrIllegalPatSynExport
      * PsWarnOperatorWhitespace
      * PsErrMultiWayIf
      * PsErrIllegalQualifiedDo
      * PsErrNumUnderscores
      * PsErrLinearFunction
      * PsErrIllegalTraditionalRecordSyntax
      * PsErrIllegalExplicitNamespace
      * PsErrOverloadedRecordUpdateNotEnabled
      * PsErrIllegalDataTypeContext
      * PsErrSemiColonsInCondExpr
      * PsErrSemiColonsInCondCmd
      * PsWarnStarIsType
      * PsWarnImportPreQualified
      * PsErrImportPostQualified
      * PsErrEmptyDoubleQuotes
      * PsErrIllegalRoleName
      * PsWarnStarBinder
      
      For some reason, this patch increases the peak_megabyte_allocated of
      the T11545 test to 90 (from a baseline of 80) but that particular test
      doesn't emit any parsing diagnostic or hint and the metric increase
      happens only for the `aarch64-linux-deb10`.
      
      Metric Increase:
          T11545
      a181313e
  31. Jun 29, 2021
  32. Mar 10, 2021
  33. Mar 09, 2021
    • Simon Peyton Jones's avatar
      Fixes to dealing with the export of main · 8fe274e2
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      It's surprisingly tricky to deal with 'main' (#19397). This
      patch does quite bit of refactoring do to it right. Well,
      more-right anyway!
      
      The moving parts are documented in GHC.Tc.Module
         Note [Dealing with main]
      
      Some other oddments:
      
      * Rename tcRnExports to rnExports; no typechecking here!
      
      * rnExports now uses checkNoErrs rather than failIfErrsM;
        the former fails only if rnExports itself finds errors
      
      * Small improvements to tcTyThingCategory, which ultimately
        weren't important to the patch, but I've retained as
        a minor improvement.
      8fe274e2
  34. Mar 01, 2021
    • Simon Peyton Jones's avatar
      Unify result type earlier to improve error messages · 7730713b
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #19364 helpfully points out that we do not currently take
      advantage of pushing the result type of an application into the
      arguments.  This makes error messages notably less good.
      
      The fix is rather easy: move the result-type unification step earlier.
      It's even a bit more efficient; in the the checking case we now
      do one less zonk.
      
      See Note [Unify with expected type before typechecking arguments]
      in GHC.Tc.Gen.App
      
      This change generally improves error messages, but it made one worse:
      typecheck/should_fail/T16204c. That led me to the realisation that
      a good error can be replaced by a less-good one, which provoked
      me to change GHC.Tc.Solver.Interact.inertsCanDischarge.  It's
      explained in the new Note [Combining equalities]
      
      One other refactoring: I discovered that KindEqOrigin didn't need a
      Maybe in its type -- a nice simplification.
      7730713b
  35. Feb 16, 2021
    • Adam Gundry's avatar
      Implement NoFieldSelectors extension (ghc-proposals 160) · 2521b041
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      
      Fixes #5972. This adds an extension NoFieldSelectors to disable the generation
      of selector functions corresponding to record fields.  When this extension is
      enabled, record field selectors are not accessible as functions, but users are
      still able to use them for record construction, pattern matching and updates.
      See Note [NoFieldSelectors] in GHC.Rename.Env for details.
      
      Defining the same field multiple times requires the DuplicateRecordFields
      extension to be enabled, even when NoFieldSelectors is in use.
      
      Along the way, this fixes the use of non-imported DuplicateRecordFields in GHCi
      with -fimplicit-import-qualified (fixes #18729).
      
      Moreover, it extends DisambiguateRecordFields to ignore non-fields when looking
      up fields in record updates (fixes #18999), as described by
      Note [DisambiguateRecordFields for updates].
      
      Co-authored-by: default avatarSimon Hafner <hafnersimon@gmail.com>
      Co-authored-by: default avatarFumiaki Kinoshita <fumiexcel@gmail.com>
      2521b041
  36. Jan 22, 2021
    • Alfredo Di Napoli's avatar
      Fix tests relying on same-line diagnostic ordering · c36a4f63
      Alfredo Di Napoli authored and Marge Bot's avatar Marge Bot committed
      This commit fixes 19 tests which were failing due to the use of
      `consBag` / `snocBag`, which have been now replaced by `addMessage`.
      This means that now GHC would output things in different order but
      only for /diagnostics on the same line/, so this is just reflecting
      that. The "normal" order of messages is still guaranteed.
      c36a4f63
  37. Jan 17, 2021
  38. Dec 24, 2020
    • Adam Gundry's avatar
      Refactor renamer datastructures · 6f8bafb4
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      This patch significantly refactors key renamer datastructures (primarily Avail
      and GlobalRdrElt) in order to treat DuplicateRecordFields in a more robust way.
      In particular it allows the extension to be used with pattern synonyms (fixes
      where mangled record selector names could be printed instead of field labels
      (e.g. with -Wpartial-fields or hole fits, see new tests).
      
      The key idea is the introduction of a new type GreName for names that may
      represent either normal entities or field labels.  This is then used in
      GlobalRdrElt and AvailInfo, in place of the old way of representing fields
      using FldParent (yuck) and an extra list in AvailTC.
      
      Updates the haddock submodule.
      6f8bafb4
Loading