Skip to content
Snippets Groups Projects
  1. Apr 11, 2025
  2. Apr 10, 2025
    • sheaf's avatar
      checkFamApp: don't be so eager to cycle break · bc73a78d
      sheaf authored and Marge Bot's avatar Marge Bot committed
      As remarked in #25933, a pure refactoring of checkTyEqRhs in
      ab77fc8c inadvertently changed behaviour,
      as it caused GHC to introduce cycle-breaker variables in some
      unnecessary circumstances.
      
      This commit refactors 'GHC.Tc.Utils.Unify.checkFamApp' in a way that
      should restore the old behaviour, so that, when possible, we first
      recur into the arguments and only introduce a cycle breaker if this
      recursion fails (e.g. due to an occurs check failure).
      
      Fixes #25933
      bc73a78d
    • Vladislav Zavialov's avatar
      Retry type/class declarations and instances (#12088) · 5712e0d6
      Vladislav Zavialov authored
      Retry type/class declarations and instances to account for non-lexical
      dependencies arising from type/data family instances.
      
      This patch improves the kind checker's ability to use type instances in kind
      checking of other declarations in the same module.
      
      * Key change: tcTyAndClassDecls now does multiple passes over the TyClGroups,
        as long as it is able to make progress.
        See the new Note [Retrying TyClGroups] in GHC.Tc.TyCl
      
      * Supporting change: FVs of a TyClGroup are now recorded in its extension
        field, namely XCTyClGroup.
        See the new Note [Prepare TyClGroup FVs] in GHC.Rename.Module
      
      * Instances are no longer inserted at the earliest positions where their FVs
        are bound. This is a simplification.
        See the new Note [Put instances at the end] in GHC.Rename.Module
      
      * Automatic unpacking is now more predictable, but fewer fields get unpacked
        by default. Use explicit {-# UNPACK #-} pragmas instead.
        See the new Note [Flaky -funbox-strict-fields with type/data families]
      
      For the wide range of newly accepted programs, consult the added test cases.
      
      Fixed tickets:
          #12088, #12239, #14668, #15561, #16410, #16448, #16693,
          #19611, #20875, #21172, #22257, #25238, #25834
      
      Metric Decrease:
          T8095
      5712e0d6
  3. Apr 09, 2025
    • sheaf's avatar
      NamedDefaults: require the class to be standard · f1acdd2c
      sheaf authored and Marge Bot's avatar Marge Bot committed
      We now only default type variables if they only appear in constraints
      of the form `C v`, where `C` is either a standard class or a class with
      an in-scope default declaration.
      
      This rectifies an oversight in the original implementation of the
      NamedDefault extensions that was remarked in #25775; that implementation
      allowed type variables to appear in unary constraints which had arbitrary
      classes at the head.
      
      See the rewritten Note [How type-class constraints are defaulted] for
      details of the implementation.
      
      Fixes #25775
      Fixes #25778
      f1acdd2c
    • Andreas Klebinger's avatar
      Avoid oversaturing constructor workers. · dea98988
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      Constructor applications always need to take the exact number of
      arguments. If we can't ensure that instead apply the constructor worker
      like a regular function.
      
      Fixes #23865
      dea98988
    • Rodrigo Mesquita's avatar
      docs: Improve haddock of ExecComplete · 501b015e
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      501b015e
    • Rodrigo Mesquita's avatar
      driver: Split Session functions out of Main · bff645ab
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      This commit moves out functions that help in creating and validating a
      GHC multi session from Main into the ghc library where they can be used by
      other GHC applications.
      
      Moreover, `Mode` processing and `checkOptions` linting were moved to
      separate modules within the ghc-bin executable package.
      
      In particular:
      
      - Move `Mode` types and functions (referring to the mode GHC is running
        on) to `ghc-bin:GHC.Driver.Session.Mode`
      
      - Move `checkOptions` and aux functions, which validates GHC DynFlags
        based on the mode, to `ghc-bin:GHC.Driver.Session.Lint`
      
      - Moves `initMulti`, `initMake`, and aux functions, which initializes a make/multi-unit
        session, into `ghc:GHC.Driver.Session.Units`.
      bff645ab
    • sheaf's avatar
      TcRnIllegalTermLevelUse: simpler error when possible · 97c884e2
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit makes GHC emit a simple error message in the case of an
      illegal term-level use of a data constructor: we will try to report an
      out-of-scope error instead of a "Illegal term level use" error, as the
      latter might be a bit overwhelming for newcomers.
      
      We do this when we have a data constructor import suggestion to provide
      to the user. For example:
      
        module M where { data A = A }
      
        module N where
          import M(A)
      
          x = Bool
          -- Illegal term-level use of Bool
      
          y = A
          -- Data constructor not in scope: A.
          -- Perhaps add 'A' to the import list of 'M'.
      
      This commit also revamps the "similar names" suggestion mechanism,
      and in particular its treatment of name spaces. Now, which name spaces
      we suggest is based solely on what we are looking for, and no longer on
      the NameSpace of the Name we have. This is because, for illegal term-level
      use errors, it doesn't make much sense to change the suggestions based
      on the fact that we resolved to e.g. a type constructor/class; what
      matters is what we were expecting to see in this position.
      See GHC.Rename.Unbound.{suggestionIsRelevant,relevantNameSpace} as well
      as the new constructors to GHC.Tc.Errors.Types.WhatLooking.
      
      Fixes #23982
      97c884e2
    • sheaf's avatar
      Store user-written qualification in the GhcRn AST · ecfec4df
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit ensures we store the original user-written module
      qualification in the renamed AST. This allows us to take into account
      the user-written qualification in error messages.
      
      Fixes #25877
      ecfec4df
  4. Apr 08, 2025
    • Matthew Pickering's avatar
      driver: refactor: Split downsweep and MakeAction into separate modules. · 99a3affd
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This will facilitate using the downsweep functions in other parts of
      the compiler than just --make mode.
      
      Also, the GHC.Driver.Make module was huge. Now it's still huge but
      slightly smaller!
      99a3affd
    • Rodrigo Mesquita's avatar
      debugger: Add breakpoints to every Stmt · 629be068
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      While single-stepping through a Haskell program we stop at every
      breakpoint. However, we don't introduce breakpoints at every single
      expression (e.g. single variables) because they would be too many and
      uninteresting.
      
      That said, in a do-block, it is expected that stepping over would break
      at every line, even if it isn't particularly interesting (e.g. a single
      arg like getArgs). Moreover, let-statements in do-blocks, despite only
      being evaluated once needed, lead to surprising jumps while stepping
      through because some have outermost (outside the let) breakpoints
      while others don't.
      
      This commit makes every statement in a do-block have a breakpoint.
      This leads to predictable stepping through in a do-block.
      Duplicate breakpoints in the same location are avoided using the
      existing blacklist mechanism, which was missing a check in one relevant place.
      
      Fixes #25932
      629be068
    • sheaf's avatar
      Turn on implicit-rhs-quantification by default · 48917d3c
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This flag was added to GHC 9.8, and will be removed in a future GHC
      release. In preparation, this commit adds it to the default warning
      flags.
      48917d3c
    • sheaf's avatar
      Implicit quantification in type synonyms: add test · 4871f543
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This adds a test for ticket #24090, which involves implicit
      quantification in type synonyms.
      The underlying issue was fixed in 0d4ee209.
      4871f543
    • Rodrigo Mesquita's avatar
      debugger: Move context utils from GHCi to GHC · 5528771c
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Moves `enclosingTickSpan`, `getCurrentBreakSpan`, and
      `getCurrentBreakModule`, general utilities on the internal debugger
      state, into the GHC library.
      5528771c
    • Rodrigo Mesquita's avatar
      debugger: derive Ord for BreakpointIds · 4f728d21
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      4f728d21
    • Rodrigo Mesquita's avatar
      Refactor and move logic for identifier breakpoints · bc0b9f73
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Breakpoints can be set on functions using syntax of the form
      `[Module.]function`. The parsing, resolution (e.g. inferring implicit
      module), and validation of this syntax for referring to functions was
      tightly coupled with its GHCi use.
      
      This commit extracts the general purpose bits of resolving this syntax
      into `GHC.Runtime.Debugger.Breakpoints` so it can be further used by
      other GHC applications and to improve the code structure of GHCi.
      
      Moreover, a few utilities that do splitting and joining of identifiers
      as strings were moved to `GHC.Runtime.Eval.Utils`, which also can be
      used in the future to clean up `GHC.Runtime.Eval` a bit.
      bc0b9f73
    • Rodrigo Mesquita's avatar
      Move logic to find and set Breakpoint to GHC · 5dba052d
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Breakpoints are uniquely identified by a module and an index unique
      within that module. `ModBreaks` of a Module contains arrays mapping from
      this unique breakpoint index to information about each breakpoint. For
      instance, `modBreaks_locs` stores the `SrcSpan` for each breakpoint.
      
      To find a breakpoint using the line number you need to go through all
      breakpoints in the array for a given module and look at the line and
      column stored in the `SrcSpan`s. Similarly for columns and finding
      breakpoints by name.
      
      This logic previously lived within the `GHCi` application sources,
      however, it is common to any GHC applications wanting to set
      breakpoints, like the upcoming `ghc-debugger`.
      
      This commit moves this logic for finding and setting breakpoints to the
      GHC library so it can be used by both `ghci` and `ghc-debugger`.
      5dba052d
    • Rodrigo Mesquita's avatar
      debugger: Add docs to obtainTermFromId · f807c590
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      f807c590
    • Cheng Shao's avatar
      testsuite: don't test WasmControlFlow stdout · ed38c09b
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch solves a potential test flakiness in `WasmControlFlow` by
      removing `WasmControlFlow.stdout` which is not so portable/stable as
      it seems. See added `Note [WasmControlFlow]` for more detailed
      explanation.
      ed38c09b
    • Andreas Klebinger's avatar
      Interpreter: Fixes to handling of subword value reads/writes. · b0dc6599
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      Load subword values as full words from the stack truncating/expanding as
      neccesary when dealing with subwords. This way byte order is implicitly
      correct.
      
      This commit also fixes the order in which we are pushing literals onto
      the stack on big endian archs.
      
      Last but not least we enable a test for ghci which actually tests these
      subword operations.
      b0dc6599
    • Andreas Klebinger's avatar
      Revert "rts: fix small argument passing on big-endian arch (fix #23387)" · 553c280b
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      Based on analysis documented in #25791 this doesn't fully fix the big
      while introducing new bugs on little endian architectures.
      
      A more complete fix will have to be implemented to fix #23387
      
      This reverts commit 4f02d3c1.
      553c280b
    • Andreas Klebinger's avatar
      NCG: AArch64 - Add -finter-module-far-jumps. · f32d6c2b
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      When enabled the arm backend will assume jumps to targets outside of the
      current module are further than 128MB away.
      
      This will allow for code to work if:
      * The current module results in less than 128MB of code.
      * The whole program is loaded within a 4GB memory region.
      
      We have seen a few reports of broken linkers (#24648) where this flag might allow
      a program to compile/run successfully at a very small performance cost.
      
      -------------------------
      Metric Increase:
          T783
      -------------------------
      f32d6c2b
  5. Apr 07, 2025
    • sheaf's avatar
      Finer-grained recompilation checking for exports · 5dade5fd
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit refines the recompilation checking logic, to avoid
      recompiling modules with an explicit import list when the modules they
      import start exporting new items.
      
      More specifically, when:
      
        1. module N imports module M,
        2. M is changed, but in a way that:
            a. preserves the exports that N imports
            b. does not introduce anything that forces recompilation downstream,
               such as orphan instances
      
      then we no longer require recompilation of N.
      
      Note that there is more to (2a) as initially meets the eye:
      
        - if N includes a whole module or "import hiding" import of M,
          then we require that the export list of M does not change,
        - if N only includes explicit imports, we check that the imported
          items don't change, e.g.
      
            - if we have @import M(T(K, f), g)@, we must check that N
              continues to export all these identifiers, with the same Avail
              structure (i.e. we should error if N stops bundling K or f with
              T)
            - if we have @import M(T(..))@, we must check that the children
              of T have not changed
      
      See Note [When to recompile when export lists change?] in GHC.Iface.Recomp.
      
      This is all tested in the new tests RecompExports{1,2,3,4,5}
      
      Fixes #25881
      5dade5fd
    • Rodrigo Mesquita's avatar
      Parametrize default logger action with Handles · f827c4c6
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Introduce `defaultLogActionWithHandles` to allow GHC applications to use
      GHC's formatting but using custom handles.
      
      `defaultLogAction` is then trivially reimplemented as
      ```
      defaultLogActionWithHandles stdout stderr
      ```
      f827c4c6
  6. Apr 04, 2025
    • Adam Gundry's avatar
      base: Minor fixes to GHC.Records haddocks · 27029e60
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      This corrects a stale reference to OverloadedRecordFields (which should
      be OverloadedRecordDot), fixes the haddock link syntax and adds an
      @since pragma.
      27029e60
    • Cheng Shao's avatar
      ci: add ghc-wasm-meta integration testing jobs · 9363e547
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds ghc-wasm-meta integration testing jobs to the CI
      pipeline, which are only triggered via the `test-wasm` MR label or
      manually when the `wasm` label is set.
      
      These jobs will fetch the wasm bindists and test them against a
      variety of downstream projects, similarly to head.hackage jobs for
      native bindists, offering a convenient way to catch potential
      downstream breakage while refactoring the wasm backend.
      9363e547
    • sheaf's avatar
      Cmm lint: lint argument types of CallishMachOps · e2237305
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit adds a new check to Cmm lint to ensure that the argument
      types to a CallishMachOp are correct. The lack of this check was
      detected in the AtomicFetch test: the literals being passed as the
      second arguments to operations such as 'fetch_add', 'fetch_and'... were
      of the wrong width, which tripped up the LLVM backend.
      e2237305
    • sheaf's avatar
      LLVM: add type annotations to AtomicFetch_cmm.cmm · 4cbc90de
      sheaf authored and Marge Bot's avatar Marge Bot committed
      4cbc90de
    • sheaf's avatar
      NamedDefaults: handle poly-kinded unary classes · d99eb7cd
      sheaf authored and Marge Bot's avatar Marge Bot committed
      With this commit, we accept named default declarations for poly-kinded
      classes such as Typeable, e.g.
      
        default Typeable (Char)
      
      This used to fail because we assumed the kind of the class was monomorphic,
      e.g.
      
        Type -> Constraint
        (Type -> Type) -> Constraint
        Nat -> Constraint
      
      Now, we can handle a simple polymorphic class such as
      
        Typeable :: forall k. k -> Constraint
      
      Note that we keep the restriction that the class must only have
      one visible argument.
      
      This is all explained in the new Note [Instance check for default declarations]
      in GHC.Tc.Gen.Default.
      
      Fixes #25882
      d99eb7cd
    • Galen Sprout's avatar
      Driver: make MonadComprehensions imply ParallelListComp · 34a9b55d
      Galen Sprout authored and Marge Bot's avatar Marge Bot committed
      This commit changes GHC.Driver.Flags.impliedXFlags to make the
      MonadComprehensions extension enable the ParallelListComp extension.
      
      Fixes #25645
      34a9b55d
  7. Apr 03, 2025
  8. Apr 02, 2025
    • sheaf's avatar
      Handle named default exports separately · d0fd9370
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit changes the way we check for duplicate exports of named
      default declarations. They are now treated entirely separately from
      other exports, because in an export list of the form
      
        module M ( default Cls, Cls )
      
      the default declaration does not export the class 'Cls', but only its
      default declarations.
      
      Also fixes a bug in Backpack where named default exports were getting
      dropped entirely. No test for that.
      
      Fixes #25857
      d0fd9370
    • Matthew Pickering's avatar
      driver: Fix recompilation checking for COMPLETE pragmas · c5bf9892
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      A {-# COMPLETE P, Q #-} pragma is associated with the pattern synonyms P
      and Q during recompilation checking. Therefore, the existence of a
      pattern synonym becomes part of the ABI hash for P and Q.
      
      Then if a module uses these pattern synonyms and a complete pragma
      changes, it will trigger recompilation in that module.
      
      Fixes #25854
      c5bf9892
    • Matthew Pickering's avatar
      driver: Fix recompilation checking for exported defaults · ccdf979b
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Since the exported defaults are not associated with any identifier from
      the module, they are just added to the export hash rather than
      the fine-grained recompilation logic.
      
      Fixes #25855
      ccdf979b
    • Matthew Pickering's avatar
      Use unsafePerformIO in definition of computeFingerprint · 2d419d8d
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      computeFingerprint is morally a pure function, which is implemented by
      mutating a buffer. Using unsafePerformIO inside the definition allows it
      to be used in pure contexts, fixing one place where an ad-hoc call to
      unsafePerformIO is already needed.
      2d419d8d
  9. Mar 31, 2025
    • Patrick's avatar
      Fix deadlock/loop in interface rehydration (#25858) · d5ea80c6
      Patrick authored and Marge Bot's avatar Marge Bot committed
      In #25858, GHC hangs when processing modules with class defaults due to a
      circular dependency in the interface rehydration process. The deadlock/loop
      occurred when eager class defaults rehydration accessed not-yet-complete module details.
      
      To fix the immediate deadlock/loop.
      `tcIfaceDefaults` is refactored, we use the class name directly from the iface
      and use `forM` for lazy loading the class, which algins with the handling of other fields
      of ModDetails. This laziness ensure rehydration waits for HomePackageTable (HPT) to
      be updated and prevent premature evaluation of ModDetails inside `fixIO``.
      
      As suggested by Matthew, class defaults importing is also refactored
      to align with the compiler's established interface loading conventions.
      - add class defaults field to ExternalPackageState (EPS).
      - rehydrate and store class defaults in EPS at `loadInterface`.
      - Instead of using `tcIfaceDefaults` in `tcRnImports`, we add and use
        `tcGetClsDefaults` to read defaults directly from HPT or EPS
        when importing modules.
      
      Tests:
      - T25858, T25858v1-2: Test class hydration in defaults
      - T25858v3-4: Test type list hydration in defaults
      
      New Note [Tricky rehydrating IfaceDefaults loop] is added.
      
      Thanks to @sheaf (Sam), @mpickering (Matthew), and @simonpj (Simon) for their
      valuable input and analysis.
      
      Fixes #25858.
      d5ea80c6
Loading