1. 03 Jul, 2020 9 commits
  2. 02 Jul, 2020 4 commits
  3. 01 Jul, 2020 5 commits
    • Ryan Scott's avatar
      Desugar quoted uses of DerivingVia and expression type signatures properly · 76d8cc74
      Ryan Scott authored
      The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g.,
      `deriving via forall a. [a] instance Eq a => Eq (List a)`) and
      explicit type annotations in signatures (e.g.,
      `f = id @a :: forall a. a -> a`) was completely wrong, as it did not
      implement the scoping guidelines laid out in
      `Note [Scoped type variables in bindings]`. This is easily fixed.
      
      While I was in town, I did some minor cleanup of related Notes:
      
      * `Note [Scoped type variables in bindings]` and
        `Note [Scoped type variables in class and instance declarations]`
        say very nearly the same thing. I decided to just consolidate the
        two Notes into `Note [Scoped type variables in quotes]`.
      * `Note [Don't quantify implicit type variables in quotes]` is
        somewhat outdated, as it predates GHC 8.10, where the
        `forall`-or-nothing rule requires kind variables to be explicitly
        quantified in the presence of an explicit `forall`. As a result,
        the running example in that Note doesn't even compile. I have
        changed the example to something simpler that illustrates the
        same point that the original Note was making.
      
      Fixes #18388.
      76d8cc74
    • Hécate Moonlight's avatar
      5c9fabb8
    • Simon Peyton Jones's avatar
      Improve debug tracing for substitution · b316804d
      Simon Peyton Jones authored
      This patch improves debug tracing a bit (#18395)
      
      * Remove the ancient SDoc argument to substitution, replacing it
        with a HasDebugCallStack constraint. The latter does the same
        job (indicate the call site) but much better.
      
      * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe
        I needed this to help nail the lookupIdSubst panic in
        #18326, #17784
      b316804d
    • Martin Handley's avatar
      #17169: Clarify Fixed's Enum instance. · fb5a0d01
      Martin Handley authored
      fb5a0d01
    • Vladislav Zavialov's avatar
      Implement -XLexicalNegation (GHC Proposal #229) · cbb6b62f
      Vladislav Zavialov authored
      This patch introduces a new extension, -XLexicalNegation, which detects
      whether the minus sign stands for negation or subtraction using the
      whitespace-based rules described in GHC Proposal #229.
      
      Updates haddock submodule.
      cbb6b62f
  4. 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
  5. 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
  6. 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
  7. 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
  8. 25 Jun, 2020 5 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