Skip to content
Snippets Groups Projects
  1. Jan 23, 2025
  2. Jan 22, 2025
    • Vladislav Zavialov's avatar
      Rework built-in and punned names (#25174, #25179, #25180, #25182) · 51e3ec83
      Vladislav Zavialov authored
      This patch rewrites part of the logic for dealing with built-in and
      punned names, making it more principled and fixing a few bugs.
      
      * Kill off filterCTuple. Its purpose was to improve pretty-printing of
        constraint tuples, and the appropriate place for this is namePun_maybe.
      
      * Remove unitTyCon, unboxedUnitTyCon, and soloTyCon from wiredInTyCons.
        Their inclusion in the list was a workaround for shoddy logic in
        lookupOrigNameCache. Now we treat tuples of all arities uniformly.
      
      * In isBuiltInOcc_maybe, only match on actual built-in syntax, e.g. "FUN"
        shouldn't be there (#25174). Also take ListTuplePuns into account (#25179).
      
      * When matching OccNames, use the ShortByteString directly to avoid
        potentially costly conversions to ByteString and String.
      
      * Introduce isInfiniteFamilyOrigName_maybe, a purpose-built helper for
        looking up tuples/sums in the OrigNameCache. This clears up the previously
        convoluted relation between the orig name cache and built-in syntax.
      
      * Reuse isKnownOrigName_maybe to eliminate the need for isPunOcc_maybe.
      
      * Classify MkSolo and MkSolo# as UserSyntax, thus fixing whole-module
        reexports (#25182).
      
      * Teach valid-hole-fits about tuples, unboxed tuples, and unboxed sums,
        up to a certain arity (#25180).
      
      * Drop the unnecessary special case for unary constraint tuples in the
        type checker (finish_tuple). It was a workaround for the lack of CSolo.
      
      * Update Notes and other comments, add tests.
      51e3ec83
  3. Jan 21, 2025
    • Jens Petersen's avatar
      hp2ps/Utilities.c: add extern parameter types for malloc and realloc for C23 · f983a00f
      Jens Petersen authored and Marge Bot's avatar Marge Bot committed
      Fix build with gcc-15 which defaults to C23 standard (-std=gnu23)
      Fixes #25662
      ```
      utils/hp2ps/Utilities.c:6:14: error:
           warning: conflicting types for built-in function ‘malloc’; expected ‘void *(long unsigned int)’ [-Wbuiltin-declaration-mismatch]
              6 | extern void* malloc();
                |              ^~~~~~
        |
      6 | extern void* malloc();
        |              ^
      utils/hp2ps/Utilities.c:5:1: error:
           note: ‘malloc’ is declared in header ‘<stdlib.h>’
              4 | #include "Error.h"
            +++ |+#include <stdlib.h>
              5 | 
        |
      5 | 
        | ^
      utils/hp2ps/Utilities.c: In function ‘xmalloc’:
      utils/hp2ps/Utilities.c:80:17: error:
           error: too many arguments to function ‘malloc’; expected 0, have 1
             80 |     r = (void*) malloc(n);
                |                 ^~~~~~ ~
         |
      80 |     r = (void*) malloc(n);
         |                 ^
      utils/hp2ps/Utilities.c:6:14: error:
           note: declared here
              6 | extern void* malloc();
                |              ^~~~~~
        |
      6 | extern void* malloc();
        |              ^
      utils/hp2ps/Utilities.c: In function ‘xrealloc’:
      utils/hp2ps/Utilities.c:92:18: error:
           warning: conflicting types for built-in function ‘realloc’; expected ‘void *(void *, long unsigned int)’ [-Wbuiltin-declaration-mismatch]
             92 |     extern void *realloc();
                |                  ^~~~~~~
         |
      92 |     extern void *realloc();
         |                  ^
      utils/hp2ps/Utilities.c:92:18: error:
           note: ‘realloc’ is declared in header ‘<stdlib.h>’
         |
      92 |     extern void *realloc();
         |                  ^
      utils/hp2ps/Utilities.c:94:9: error:
           error: too many arguments to function ‘realloc’; expected 0, have 2
             94 |     r = realloc(p, n);
                |         ^~~~~~~ ~
         |
      94 |     r = realloc(p, n);
         |         ^
      utils/hp2ps/Utilities.c:92:18: error:
           note: declared here
             92 |     extern void *realloc();
                |                  ^~~~~~~
         |
      92 |     extern void *realloc();
         |                  ^
      ```
      f983a00f
    • Rodrigo Mesquita's avatar
      driver: Store the HomePackageTable in a mutable reference · 6b7ea592
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      
      This commit refactors the HomePackageTable and HomeUnitGraph:
      
      (1) It fixes a quadratic-in-the-number-of-modules space leak in upsweep (#25511)
      
      (2) And it reworks these structures into their own modules to simplify
          the driver. The refactor is driven by the introduction of IO in the HPT
          interface, but is a bit more aggressive in simplifying the
          interfaces to enforce correct usage (ie to avoid performance
          pitfalls).
      
      Specifically:
      
      - The `HomeUnitGraph` (HUG) is now in `GHC.Unit.Home.Graph`
      - The `HomePackageTable` (HPT) is now in `GHC.Unit.Home.PackageTable`
          - The HPT now stores an `IORef` with the table of loaded home package modules.
          - The interface to the HPT now requires IO
          - The interface now enforces that the HPT is a datastructure that
            only grows
          - This is not enforced in the interface, but, clients of the HPT
            should never care about there being more or less entries in the
            HPT when these additional entries are not relevant to their result.
          - The exception to the invariant that the HPT is monotonically
            increasing is `restrictHpt`, a function which is called at a
            "barrier point" (during which there are no other threads
            inspecting or inserting in the HPT). The invariant can be
            temporarily broken at this point (currently, after upsweep).
            This is safe because a single thread holds control over the
            structure (thus the invariant being broken is never observed).
      
      The hug_var and associated structures in the driver, which aimed to
      improve memory usage in the driver by updating in place a HUG during
      upsweep, are no longer required as the HPT entries in the HUG are now
      themselves mutable by construction. This was previously explained in
      Note [ModuleNameSet, efficiency and space leaks], which is no longer
      relevant and was deleted.
      
      Fixes #25511
      
      Co-authored-by: default avatarMatthew Pickering <matthewtpickering@gmail.com>
      
      -------------------------
      Metric Decrease:
          MultiComponentModulesRecomp
          MultiLayerModulesRecomp
      -------------------------
      6b7ea592
    • Ryan Scott's avatar
      Fix :info pretty-printing of UNPACKed fields · 09ee3247
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This patch:
      
      * Ensures that we do not pretty-print a field like `foo :: {-# UNPACK #-} !Int`
        as `foo :: ! {-# UNPACK -#} Int` (as we were doing before) when running the
        `:info` command.
      * Prevents coercions that arise from `UNPACK`ed fields (e.g., such as when one
        unpacks a newtype) from being printed in `:info` output unless `-dppr-debug`
        is enabled.
      
      Fixes #25651.
      09ee3247
    • Ben Gamari's avatar
      compiler: Fix CPP guards around ghc_unique_counter64 · 595013d4
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      The `ghc_unique_counter64` symbol was introduced in the RTS in the
      64-bit unique refactor (!10568) which has been backported to %9.6.7 and
      %9.8.4. Update the CPP to reflect this.
      
      Fixes #25576.
      595013d4
  4. Jan 20, 2025
    • Cheng Shao's avatar
      hie: fix hie.yaml to use default hie-bios script · b3c0acfc
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      !13778 accidentally changed hie.yaml to use hie-bios.bat as the
      default hie-bios script, which completely breaks hie support on
      non-Windows platforms. This patch reverts that change.
      b3c0acfc
    • Matthew Pickering's avatar
      driver: Store an ExternalModuleGraph in the EPS · 44778963
      Matthew Pickering authored
      
      We now store an ExternalModuleGraph in the EPS. When an new interface is
      loaded, the module graph is extended with a node for the loaded
      interface. The result is a partial module graph. If you want to run
      a transitive closure query on the graph you must first force the
      transitive closure to be loaded by using `loadExternalGraphBelow`.
      
      The primary advantage (for now) is that the transitive dependency
      calculation does not have to be repeated in getLinkDeps. If your module
      had many dependencies and many splices, performing this calculation at
      every splice site took a significant amount of time.
      
      We might also want to use this module graph in future for considering
      questions such as reachability of rules or accessibilty of instance
      imported by levelled imported.
      
      This patch removes another place in the compiler where transitive
      dependency is calculated in an ad-hoc manner. In general, the transitive
      dependency calculation should be cached and computed using a ModuleGraph
      abstraction.
      
      The transitive dependency query required by getLinkDeps operates on a
      graph without hs-boot nodes. If a linkable from a module in a loop is
      needed, then all modules in the loop are necessary to be available to
      execute that module. Therefore there is a query in `ModuleGraph` and
      `ExternalModuleGraph` which allows a transitive closure query to be
      performed on a graph without loops.
      
      Fixes #25634
      
      -------------------------
      Metric Decrease:
          MultiLayerModulesTH_Make
          MultiLayerModulesTH_OneShot
      Metric Increase:
          mhu-perf
      -------------------------
      
      Co-authored-by: default avatarRodrigo Mesquita <rodrigo.m.mesquita@gmail.com>
      44778963
  5. Jan 18, 2025
  6. Jan 17, 2025
  7. Jan 16, 2025
    • sheaf's avatar
      Use checkTyEqRhs to make types concrete · 87e82e2e
      sheaf authored
      This commit refactors makeTypeConcrete to call checkTyEqRhs with
      the appropriate parameters. This avoids duplicating subtle logic
      in two places in the compiler.
      
      Changes:
      
        1. Refactor of 'TyEqFlags'. Now 'TyEqFlags' stores a 'TEFTask', which
           is a description of which of the following checks we want to
           perform in 'checkTyEqRhs':
              - occurs check
              - level check
              - concreteness check
      
           In the process, the 'AreUnifying' datatype has been removed, as it
           is no longer needed.
      
        2. Refactor of 'checkTyVar':
            a. Make use of the new 'TEFTask' data type to decide which checks
               to perform.
               In particular, this ensures that we perform **both** a
               concreteness check and a level check when both are required;
               previously we only did a concreteness check (that was a bug!).
            b. Recursively call 'checkTyVar' on the kind of unfilled
               metavariables. This deals with a bug in which we failed to
               uphold the invariant that the kind of a concrete type must
               itself be concrete. See test cases T23051, T23176.
      
        3. Re-write of 'makeTypeConcrete', which now simply calls
           'checkTyEqRhs' with appropriate 'TyEqFlags'/'TEFTask'.
           This gets rid of code duplication and risk for the two code paths
           going out-of-sync.
      
      Fixes #25616. See also #23883.
      87e82e2e
  8. Jan 15, 2025
    • amesgen's avatar
      wasm: prevent bundlers from resolving import("node:timers") · f6493dbc
      amesgen authored and Marge Bot's avatar Marge Bot committed
      This fixes the following esbuild error:
      
          ✘ [ERROR] Could not resolve "node:timers"
      
              www/ghc_wasm_jsffi.js:66:25:
                66 │     return (await import("node:timers")).setImmediate;
                   ╵                          ~~~~~~~~~~~~~
      
            The package "node:timers" wasn't found on the file system but is built into node. Are you trying
            to bundle for node? You can use "--platform=node" to do that, which will remove this error.
      
      Previously (i.e. after !13503), one had to work around this by passing
      `--external:node:timers`.
      f6493dbc
  9. Jan 13, 2025
    • Patrick's avatar
      Enhance kind inference for data family instances · 3d9cacd5
      Patrick authored
      This commit improves kind inference for data family instances by kind-checking
      the constructors, for H98 and newtype declarations (ONLY), as well as
      kind-checking the result kind signature (when using GADT syntax).
      This fixes #25611.
      
      Typechecker changes:
      In `tcDataFamInstHeader`, we now kind-check the constructors using
      `kcConDecls`, for H98-style decls and newtype decls ONLY.
      See Note [Kind inference for data family instances].
      
      Testsuite changes:
        - The T25611{a,b,c,d} tests test the new kind inference implementation.
          - a,b: infer result kind from constructors (H98 case)
          - c: renamed version of test UnliftedNewtypesUnassociatedFamilyFail,
            which now passes
          - d: GADT case, checking that we don't infer overly rigid kinds when
               kind-checking the constructors in data family instances.
       - DataInstanceKindsDefaults tests defaulting data instance kinds
         without UnliftedNewtypes or UnliftedDatatypes, as outlined in
         Note [Defaulting result kind of newtype/data family instance].
      
      Also a few notes are updated to reflect the changes.
      
      Co-authored-by: default avatardefault avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      3d9cacd5
    • Luite Stegeman's avatar
      compiler/coreprep: Turn off dictionary speculation by default · ab3ab3e3
      Luite Stegeman authored and Marge Bot's avatar Marge Bot committed
      Speculative evaluation can cause performance regressions,
      therefore we turn it off by default. It can be enabled again
      with the -fspec-eval-dictfun flag
      
      See #25284
      ab3ab3e3
    • Mike Pilgrem's avatar
      Re CLC #300 - Specify fmap for NonEmpty as map · 2d62b970
      Mike Pilgrem authored and Marge Bot's avatar Marge Bot committed
      See:
      * https://github.com/haskell/core-libraries-committee/issues/300
      
      Seeks to:
      * move existing instances for NonEmpty (except of Eq and Ord) out of GHC.Internal.Base into new GHC.Internal.Data.NonEmpty (to avoid otherwise unavoidable cycles in the module graph);
      * move map out of Data.List.NonEmpty (base package) into GHC.Internal.Data.NonEmpty;
      * define fmap as map for NonEmpty instance of Functor, avoiding code duplication;
      * re-export map from existing GHC.Internal.Data.List.NonEmpty; and
      * re-export map from Data.List.NonEmpty (base package);
      
      without breaking anything in the GHC repository.
      
      Various tests *.stdout and *.stderr files are amended also.
      2d62b970
    • sheaf's avatar
      Remove SDocs from ErrCtxt & ErrInfo · 2e7bf446
      sheaf authored
      This commit:
      
        - turns the SDoc used in ErrCtxt into a proper error datatype,
          ErrCtxtMsg, which contains all the different error contexts that
          can be added,
      
        - replaces ErrInfo with [ErrCtxt].
          ErrInfo used to contain two SDocs; the first is replaced with [ErrCtxt],
          and the second is removed, with the relevant information being put
          in the appropriate error message constructors.
      
      Fixes #23436
      2e7bf446
  10. Jan 10, 2025
    • Ben Gamari's avatar
      dump-decls: Suppress unit-ids · e1c133f2
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      While the testsuite driver already normalizes these away, they are
      nevertheless a severe nuisance when diffing outside of the testsuite.
      
      Intriguingly, this doesn't completely eliminate the unit IDs; some
      wired-in names are still printed. However, this is a cheap and helpful
      improvement over the status quo so I am simply going to accept this.
      
      Fixes #25334.
      e1c133f2
    • Rodrigo Mesquita's avatar
      user_guide: Note -pgmP/-optP are for /Haskell/-CPP · 023f36f5
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Fixes #25574
      023f36f5
  11. Jan 09, 2025
  12. Jan 07, 2025
    • Luite Stegeman's avatar
      Add flags for switching off speculative evaluation. · 23099752
      Luite Stegeman authored
      We found that speculative evaluation can increase the amount of
      allocations in some circumstances. This patch adds new flags for
      selectively disabling speculative evaluation, allowing us to
      test the effect of the optimization.
      
      The new flags are:
      
        -fspec-eval
           globally enable speculative evaluation
      
        -fspec-eval-dictfun
           enable speculative evaluation for dictionary functions (no effect
           if speculative evaluation is globally disabled)
      
      The new flags are on by default for all optimisation levels.
      
      See #25284
      23099752
    • sheaf's avatar
      Fix typo in GHC.Tc.Solver.Solve.runTcPluginsWanted · 185f17e4
      sheaf authored and Marge Bot's avatar Marge Bot committed
      185f17e4
    • Cheng Shao's avatar
      xxhash: bump to v0.8.3 · 42826a89
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      42826a89
    • Bryan R's avatar
      Remove tmp files after toolchain check · 6c12b6cf
      Bryan R authored and Marge Bot's avatar Marge Bot committed
      Fixes #25620
      6c12b6cf
    • Simon Peyton Jones's avatar
      Tidy up kcConDecls · 84155cdb
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Addresses #25630
      
      In particular,
      
      * Introduce ConArgKind and use it.
      
      * Make kcConDecls and tcConDecls work the same way
        concerning the kind of argument types
      84155cdb
    • Matthew Pickering's avatar
      warnings: Find out if a qualified name is in the interactive scope directly · f56558be
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      There were two ad-hoc mechanisms used to determine which modules were in
      the interactive scope.
      
      1. Look at everything in the GRE, to see what is imported qualified.
      2. Look at the last loaded module in the HPT.
      
      (1) Is very inefficient, GlobalRdrEnvs can be very big.
      (2) is incorrect, there is no reason to assume the "last" thing added to
      the HPT has any relevance to module loading order.
      
      Happily, the same checks can be implemented directly by looking at the
      interactive imports from the interactive context. This mirrors what
      happens for normal imports.
      
      Arguably, the error reporting code shouldn't be doing this kind of
      processing and it should be an option is set when rendering the error
      message. However, this just improves the situation and doesn't block
      progress on that front in future.
      
      See #14225 and #15611
      
      Fixes #25600
      f56558be
  13. Dec 30, 2024
  14. Dec 29, 2024
    • Simon Peyton Jones's avatar
      Fix in-scope set for CSE · c02b1e46
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #25468 showed an assertion failure in CSE because a top-level
      Id was being used before it was defined.  Reason: Note [Glomming] in
      GHC.Core.Opt.OccurAnal.
      
      Solution (used in many places): just put all the top-level bindings in
      scope at the beginning of CSE.
      
      Compile-time allocation wobbles up and down a tiny bit; geo mean is
      zero. But MultiLayerModulesTH_OneShot and hard_hole_fits increase (on
      some architectures only) by a bit oever 2% .  I think these are just a
      random fluctuations.
      
      Metric Increase:
          MultiLayerModulesTH_OneShot
          hard_hole_fits
      c02b1e46
    • Zubin's avatar
      hadrian-multi: warn on unused imports · fafb70db
      Zubin authored and Zubin's avatar Zubin committed
      os-string has redundant imports
      
      (cherry picked from commit dde3796b)
      fafb70db
Loading