1. 30 Jun, 2020 4 commits
    • Joshua Price's avatar
    • David Eichmann's avatar
      81704a6f
    • Sylvain Henry's avatar
      Add ghc-bignum to 8.12 release notes · bccf3351
      Sylvain Henry authored
      bccf3351
    • Ryan Scott's avatar
      Reject nested foralls/contexts in instance types more consistently · 71006532
      Ryan Scott authored
      GHC is very wishy-washy about rejecting instance declarations with
      nested `forall`s or contexts that are surrounded by outermost
      parentheses. This can even lead to some strange interactions with
      `ScopedTypeVariables`, as demonstrated in #18240. This patch makes
      GHC more consistently reject instance types with nested
      `forall`s/contexts so as to prevent these strange interactions.
      
      On the implementation side, this patch tweaks `splitLHsInstDeclTy`
      and `getLHsInstDeclHead` to not look through parentheses, which can
      be semantically significant. I've added a
      `Note [No nested foralls or contexts in instance types]` in
      `GHC.Hs.Type` to explain why. This also introduces a
      `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to
      catch nested `forall`s/contexts in instance types. This function is
      now used in `rnClsInstDecl` (for ordinary instance declarations) and
      `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter
      of which fixes #18271.
      
      On the documentation side, this adds a new
      "Formal syntax for instance declaration types" section to the GHC
      User's Guide that presents a BNF-style grammar for what is and isn't
      allowed in instance types.
      
      Fixes #18240. Fixes #18271.
      71006532
  2. 28 Jun, 2020 5 commits
    • Simon Peyton Jones's avatar
      Fix a typo in Lint · bfa5698b
      Simon Peyton Jones authored
      This simple error in GHC.Core.Litn.lintJoinLams meant that
      Lint reported bogus errors.
      
      Fixes #18399
      bfa5698b
    • Ryan Scott's avatar
      15b79bef
    • Jan Hrček's avatar
      68530b1c
    • Ryan Scott's avatar
      Use NHsCoreTy to embed types into GND-generated code · 42f797b0
      Ryan Scott authored
      `GeneralizedNewtypeDeriving` is in the unique situation where it must
      produce an `LHsType GhcPs` from a Core `Type`. Historically, this was
      done with the `typeToLHsType` function, which walked over the entire
      `Type` and attempted to construct an `LHsType` with the same overall
      structure. `typeToLHsType` is quite complicated, however, and has
      been the subject of numerous bugs over the years (e.g., #14579).
      
      Luckily, there is an easier way to accomplish the same thing: the
      `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`,
      which allows embedding a Core `Type` directly into an `HsType`,
      avoiding the need to laboriously convert from one to another (as
      `typeToLHsType` did). Moreover, renaming and typechecking an
      `XHsType` is simple, since one doesn't need to do anything to a
      Core `Type`...
      
      ...well, almost. For the reasons described in
      `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must
      apply a substitution that we build from the local `tcl_env` type
      environment. But that's a relatively modest price to pay.
      
      Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the
      `typeToLHsType` function no longer has any uses in GHC, so this patch
      rips it out. Some additional tweaks to `hsTypeNeedsParens` were
      necessary to make the new `-ddump-deriv` output correctly
      parenthesized, but other than that, this patch is quite
      straightforward.
      
      This is a mostly internal refactoring, although it is likely that
      `GeneralizedNewtypeDeriving`-generated code will now need fewer
      language extensions in certain situations than it did before.
      42f797b0
    • Peter Trommler's avatar
      RTS: Refactor Haskell-C glue for PPC 64-bit · d8ba9e6f
      Peter Trommler authored
      Make sure the stack is 16 byte aligned even when reserved stack
      bytes are not a multiple of 16 bytes.
      
      Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn
      has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the
      function prologue.
      
      Use the ABI provided functions to save clobbered GPRs and FPRs.
      
      Improve comments. Describe what the stack looks like and how it relates
      to the respective ABIs.
      d8ba9e6f
  3. 27 Jun, 2020 6 commits
    • Krzysztof Gogolewski's avatar
      Don't generalize when typechecking a tuple section · 0e83efa2
      Krzysztof Gogolewski authored
      The code is simpler and cleaner.
      0e83efa2
    • Sylvain Henry's avatar
      DynFlags: don't store buildTag · a04020b8
      Sylvain Henry authored
      `DynFlags.buildTag` was a field created from the set of Ways in
      `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which
      was fragile. We want to avoid global state like this (#17957).
      
      Moreover in #14335 we also want to support loading units with different
      ways: target units would still use `DynFlags.ways` but plugins would use
      `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build
      tag and with ways, we recompute the buildTag on-the-fly (should be
      pretty cheap) and we remove `DynFlags.buildTag` field.
      a04020b8
    • Simon Peyton Jones's avatar
      Better loop detection in findTypeShape · a74ec37c
      Simon Peyton Jones authored
      Andreas pointed out, in !3466, that my fix for #18304 was not
      quite right.  This patch fixes it properly, by having just one
      RecTcChecker rather than (implicitly) two nested ones, in
      findTypeShape.
      a74ec37c
    • Sylvain Henry's avatar
      Fix ghc-bignum exceptions · 1b3d13b6
      Sylvain Henry authored
      We must ensure that exceptions are not simplified. Previously we used:
      
         case raiseDivZero of
            _ -> 0## -- dummyValue
      
      But it was wrong because the evaluation of `raiseDivZero` was removed and
      the dummy value was directly returned. See new Note [ghc-bignum exceptions].
      
      I've also removed the exception triggering primops which were fragile.
      We don't need them to be primops, we can have them exported by ghc-prim.
      
      I've also added a test for #18359 which triggered this patch.
      1b3d13b6
    • Sylvain Henry's avatar
      ghc-bignum: fix division by zero (#18359) · a403eb91
      Sylvain Henry authored
      a403eb91
    • Ryan Scott's avatar
      Revamp the treatment of auxiliary bindings for derived instances · ce987865
      Ryan Scott authored
      This started as a simple fix for #18321 that organically grew into a
      much more sweeping refactor of how auxiliary bindings for derived
      instances are handled. I have rewritten `Note [Auxiliary binders]`
      in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but
      the highlights are:
      
      * Previously, the OccName of each auxiliary binding would be given
        a suffix containing a hash of its package name, module name, and
        parent data type to avoid name clashes. This was needlessly
        complicated, so we take the more direct approach of generating
        `Exact` `RdrName`s for each auxiliary binding with the same
        `OccName`, but using an underlying `System` `Name` with a fresh
        `Unique` for each binding. Unlike hashes, allocating new `Unique`s
        does not require any cleverness and avoid name clashes all the
        same...
      * ...speaking of which, in order to convince the renamer that multiple
        auxiliary bindings with the same `OccName` (but different
        `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of
        `rnTopBindsLHS` to rename auxiliary bindings. Again, see
        `Note [Auxiliary binders]` for the full story.
      * I have removed the `DerivHsBind` constructor for
        `DerivStuff`—which was only used for `Data.Data`-related
        auxiliary bindings—and refactored `gen_Data_binds` to use
        `DerivAuxBind` instead. This brings the treatment of
        `Data.Data`-related auxiliary bindings in line with every other
        form of auxiliary binding.
      
      Fixes #18321.
      ce987865
  4. 26 Jun, 2020 2 commits
    • Matthías Páll Gissurarson's avatar
      Implement the proposed -XQualifiedDo extension · 9ee58f8d
      Matthías Páll Gissurarson authored
      Co-authored-by: default avatarFacundo Domínguez <facundo.dominguez@tweag.io>
      
      QualifiedDo is implemented using the same placeholders for operation names in
      the AST that were devised for RebindableSyntax. Whenever the renamer checks
      which names to use for do syntax, it first checks if the do block is qualified
      (e.g. M.do { stmts }), in which case it searches for qualified names in
      the module M.
      
      This allows users to write
      
          {-# LANGUAGE QualifiedDo #-}
          import qualified SomeModule as M
      
          f x = M.do           -- desugars to:
            y <- M.return x    -- M.return x M.>>= \y ->
            M.return y         -- M.return y M.>>
            M.return y         -- M.return y
      
      See Note [QualifiedDo] and the users' guide for more details.
      
      Issue #18214
      
      Proposal:
      https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst
      
      Since we change the constructors `ITdo` and `ITmdo` to carry the new module
      name, we need to bump the haddock submodule to account or the new shape of
      these constructors.
      9ee58f8d
    • Sebastian Graf's avatar
      GHC.Core.Unify: Make UM actions one-shot by default · a3d69dc6
      Sebastian Graf authored
      This MR makes the UM monad in GHC.Core.Unify into a one-shot
      monad.  See the long Note [The one-shot state monad trick].
      
      See also #18202 and !3309, which applies this to all Reader/State-like
      monads in GHC for compile-time perf improvements. The pattern used
      here enables something similar to the state-hack, but is applicable to
      user-defined monads, not just `IO`.
      
      Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'):
          haddock.Cabal
      a3d69dc6
  5. 25 Jun, 2020 15 commits
    • Sylvain Henry's avatar
      RTS: avoid overflow on 32-bit arch (#18375) · d3c2d59b
      Sylvain Henry authored
      We're now correctly computing allocated bytes on 32-bit arch, so we get
      huge increases.
      
      Metric Increase:
          haddock.Cabal
          haddock.base
          haddock.compiler
          space_leak_001
      d3c2d59b
    • Ben Gamari's avatar
      rts/Hash: Simplify freeing of HashListChunks · a788d4d1
      Ben Gamari authored
      While looking at #18348 I noticed that the treatment of HashLists are a
      bit more complex than necessary (which lead to some initial confusion on
      my part). Specifically, we allocate HashLists in chunks. Each chunk
      allocation makes two allocations: one for the chunk itself and one for a
      HashListChunk to link together the chunks for the purposes of freeing.
      
      Simplify this (and hopefully make the relationship between these
      clearer) but allocating the HashLists and HashListChunk in a single
      malloc. This will both make the implementation easier to follow and
      reduce C heap fragmentation.
      
      Note that even after this patch we fail to bound the size of the free
      HashList pool. However, this is a separate bug.
      a788d4d1
    • Roland Senn's avatar
      Enable maxBound checks for OverloadedLists (Fixes #18172) · fe281b27
      Roland Senn authored
      Consider the Literal `[256] :: [Data.Word.Word8]`
      
      When the `OverloadedLists` extension is not active, then the `ol_ext` field
      in the `OverLitTc` record that is passed to the function `getIntegralLit`
      contains the type `Word8`. This is a simple type, and we can use its
      type constructor immediately for the `warnAboutOverflowedLiterals` function.
      
      When the `OverloadedLists` extension is active, then the `ol_ext` field
      contains the type family `Item [Word8]`. The function `nomaliseType` is used
      to convert it to the needed type `Word8`.
      fe281b27
    • Artem Pelenitsyn's avatar
      test suite: add reproducer for #17516 · c50ef26e
      Artem Pelenitsyn authored
      c50ef26e
    • Oleg Grenrus's avatar
      Add MonadZip and MonadFix instances for Complex · 67a86b4d
      Oleg Grenrus authored
      These instances are taken from
      https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html
      
      They are the unique possible, so let they be in `base`.
      67a86b4d
    • Takenobu Tani's avatar
      Clean up haddock hyperlinks of GHC.* (part2) · 1eb997a8
      Takenobu Tani authored
      This updates haddock comments only.
      
      This patch focuses to update for hyperlinks in GHC API's haddock comments,
      because broken links especially discourage newcomers.
      
      This includes the following hierarchies:
      
        - GHC.Iface.*
        - GHC.Llvm.*
      
        - GHC.Rename.*
        - GHC.Tc.*
      
        - GHC.HsToCore.*
        - GHC.StgToCmm.*
        - GHC.CmmToAsm.*
      
        - GHC.Runtime.*
      
        - GHC.Unit.*
        - GHC.Utils.*
        - GHC.SysTools.*
      1eb997a8
    • Takenobu Tani's avatar
      Clean up haddock hyperlinks of GHC.* (part1) · c7dd6da7
      Takenobu Tani authored
      This updates haddock comments only.
      
      This patch focuses to update for hyperlinks in GHC API's haddock comments,
      because broken links especially discourage newcomers.
      
      This includes the following hierarchies:
        - GHC.Hs.*
        - GHC.Core.*
        - GHC.Stg.*
        - GHC.Cmm.*
        - GHC.Types.*
        - GHC.Data.*
        - GHC.Builtin.*
        - GHC.Parser.*
        - GHC.Driver.*
        - GHC top
      c7dd6da7
    • wz1000's avatar
      Export everything from HsToCore. · 90f43872
      wz1000 authored
      This lets us reuse these functions in haddock, avoiding synchronization bugs.
      
      Also fixed some divergences with haddock in that file
      
      Updates haddock submodule
      90f43872
    • Oleg Grenrus's avatar
      Export readBinIface_ · 284001d0
      Oleg Grenrus authored
      284001d0
    • Adam Wespiser's avatar
      add examples to Data.Traversable · 8ddbed4a
      Adam Wespiser authored
      8ddbed4a
    • Simon Peyton Jones's avatar
      Expunge GhcTcId · 0d61f866
      Simon Peyton Jones authored
      GHC.Hs.Extension had
      
        type GhcPs   = GhcPass 'Parsed
        type GhcRn   = GhcPass 'Renamed
        type GhcTc   = GhcPass 'Typechecked
        type GhcTcId = GhcTc
      
      The last of these, GhcTcId, is a vestige of the past.
      
      This patch expunges it from GHC.
      0d61f866
    • Ben Gamari's avatar
      hadrian/make: Detect makeindex · 4acc2934
      Ben Gamari authored
      Previously we would simply assume that makeindex was available.
      Now we correctly detect it in `configure` and respect this conclusion in
      hadrian and make.
      4acc2934
    • Ben Gamari's avatar
      make: Respect XELATEX variable · 30e42652
      Ben Gamari authored
      Previously we simply ignored the XELATEX variable when building
      PDF documentation.
      30e42652
    • Roland Senn's avatar
      In `:break ident` allow out of scope and nested identifiers (Fix #3000) · 7e6d3d09
      Roland Senn authored
      This patch fixes the bug and implements the feature request of #3000.
      
      1. If `Module` is a real module name and `identifier` a name of a
      top-level function in `Module` then `:break Module.identifer` works
      also for an `identifier` that is out of scope.
      
      2. Extend the syntax for `:break identifier` to:
      
          :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent]
      
      `ModQual` is optional and is either the effective name of a module or
      the local alias of a qualified import statement.
      
      `topLevelIdent` is the name of a top level function in the module
      referenced by `ModQual`.
      
      `nestedIdent` is optional and the name of a function nested in a let or
      where clause inside the previously mentioned function `nestedIdent` or
      `topLevelIdent`.
      
      If `ModQual` is a module name, then `topLevelIdent` can be any top level
      identifier in this module. If `ModQual` is missing or a local alias of a
      qualified import, then `topLevelIdent` must be in scope.
      
      Breakpoints can be set on arbitrarily deeply nested functions, but the
      whole chain of nested function names must be specified.
      
      3. To support the new functionality rewrite the code to tab complete `:break`.
      7e6d3d09
    • Andreas Klebinger's avatar
      Enable large address space optimization on windows. · 03a708ba
      Andreas Klebinger authored
      Starting with Win 8.1/Server 2012 windows no longer preallocates
      page tables for reserverd memory eagerly, which prevented us from
      using this approach in the past.
      
      We also try to allocate the heap high in the memory space.
      Hopefully this makes it easier to allocate things in the low
      4GB of memory that need to be there. Like jump islands for the
      linker.
      03a708ba
  6. 24 Jun, 2020 8 commits