1. 16 Feb, 2021 4 commits
    • Ryan Scott's avatar
      Parse symbolic names in ANN type correctly with otycon · a04179e7
      Ryan Scott authored
      This adds a new `otycon` production to the parser that allows for type
      constructor names that are either alphanumeric (`tycon`) or symbolic
      (`tyconsym`), where the latter must be parenthesized appropriately.
      `otycon` is much like the existing `oqtycon` production, except that it does
      not permit qualified names. The parser now uses `otycon` to parse type
      constructor names in `ANN type` declarations, which fixes #19374.
      
      To make sure that all of this works, I added three test cases:
      
      * `should_compile/T19374a`: the original test case from #19374
      * `should_fail/T19374b`: a test that makes sure that an `ANN` with a qualified
        name fails to parse
      * `should_fail/T19374c`: a test that makes sure that an `ANN type` with a
        qualified name fails to parse
      a04179e7
    • Adam Gundry's avatar
      Avoid false redundant import warning with DisambiguateRecordFields · 7686f9f8
      Adam Gundry authored
      Fixes #17853. We mustn't discard the result of pickGREs, because doing
      so might lead to incorrect redundant import warnings.
      7686f9f8
    • Adam Gundry's avatar
      Make sure HasField use counts for -Wunused-top-binds · 1109896c
      Adam Gundry authored
      This is a small fix that depends on the previous commit, because it
      corrected the rnExpr free variable calculation for HsVars which refer
      to ambiguous fields. Fixes #19213.
      1109896c
    • Adam Gundry's avatar
      Implement NoFieldSelectors extension (ghc-proposals 160) · 2521b041
      Adam Gundry authored
      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: Simon Hafner's avatarSimon Hafner <hafnersimon@gmail.com>
      Co-authored-by: Fumiaki Kinoshita's avatarFumiaki Kinoshita <fumiexcel@gmail.com>
      2521b041
  2. 14 Feb, 2021 10 commits
    • Daniel Gröber (dxld)'s avatar
      Fix non power-of-two Storable.alignment in Capi_Ctype tests · 3deb1387
      Daniel Gröber (dxld) authored
      Alignments passed to alloca and friends must be a power of two for the code
      in allocatePinned to work properly. Commit 41230e26 ("Zero out pinned
      block alignment slop when profiling") introduced an ASSERT for this but
      this test was still violating it.
      3deb1387
    • Simon Peyton Jones's avatar
      Fix over-eager inlining in SimpleOpt · 4dc2002a
      Simon Peyton Jones authored
      In GHC.Core.SimpleOpt, I found that its inlining could duplicate
      an arbitary redex inside a lambda!  Consider (\xyz. x+y).  The
      occurrence-analysis treats the lamdda as a group, and says that
      both x and y occur once, even though the occur under the lambda-z.
      See Note [Occurrence analysis for lambda binders] in OccurAnal.
      
      When the lambda is under-applied in a call, the Simplifier is
      careful to zap the occ-info on x,y, because they appear under the \z.
      (See the call to zapLamBndrs in simplExprF1.)  But SimpleOpt
      missed this test, resulting in #19347.
      
      So this patch
      * commons up the binder-zapping in GHC.Core.Utils.zapLamBndrs.
      * Calls this new function from GHC.Core.Opt.Simplify
      * Adds a call to zapLamBndrs to GHC.Core.SimpleOpt.simple_app
      
      This change makes test T12990 regress somewhat, but it was always
      very delicate, so I'm going to put up with that.
      
      In this voyage I also discovered a small, rather unrelated infelicity
      in the Simplifier:
      
      * In GHC.Core.Opt.Simplify.simplNonRecX we should apply isStrictId
        to the OutId not the InId. See Note [Dark corner with levity polymorphism]
      
      It may never "bite", because SimpleOpt should have inlined all
      the levity-polymorphic compulsory inlnings already, but somehow
      it bit me at one point and it's generally a more solid thing
      to do.
      
      Fixing the main bug increases runtime allocation in test
      perf/should_run/T12990, for (acceptable) reasons explained in a
      comement on
      
      Metric Increase:
          T12990
      4dc2002a
    • Ben Gamari's avatar
      Introduce keepAlive primop · 74fec146
      Ben Gamari authored
      74fec146
    • Sylvain Henry's avatar
      Bignum: fix bogus rewrite rule (#19345) · 5e71dd33
      Sylvain Henry authored
      Fix the following rule:
      
        "fromIntegral/Int->Natural" fromIntegral = naturalFromWord . fromIntegral
      
      Its type wasn't constrained to Int hence #19345.
      5e71dd33
    • Simon Peyton Jones's avatar
      Fix a serious bug in roughMatchTcs · be3c0d62
      Simon Peyton Jones authored
      The roughMatchTcs function enables a quick definitely-no-match test
      in lookupInstEnv.  Unfortunately, it didn't account for type families.
      This didn't matter when type families were flattened away, but now
      they aren't flattened it matters a lot.
      
      The fix is very easy. See INVARIANT in GHC.Core.InstEnv
      Note [ClsInst laziness and the rough-match fields]
      
      Fixes #19336
      
      The change makes compiler perf worse on two very-type-family-heavy
      benchmarks, T9872{a,d}:
        T9872a(normal) ghc/alloc  2172536442.7  2216337648.0  +2.0%
        T9872d(normal) ghc/alloc   614584024.0   621081384.0  +1.1%
      (Everything else is 0.0% or at most 0.1%.)
      
      I think we just have to put up with this. Some cases were being
      wrongly filtered out by roughMatchTcs that might actually match, which
      could lead to false apartness checks.  And it only affects these very
      type-family-heavy cases.
      
      Metric Increase:
          T9872a
          T9872d
      be3c0d62
    • Krzysztof Gogolewski's avatar
      Remove deprecated -XGenerics and -XMonoPatBinds · dcc4b2de
      Krzysztof Gogolewski authored
      They have no effect since 2011 (GHC 7.2/7.4),
      commits cb698570 and 49dbe605.
      dcc4b2de
    • Krzysztof Gogolewski's avatar
      Add tests for solved arrow tickets #5777 #15175 · 18e53386
      Krzysztof Gogolewski authored
      Merge requests !4464 and !4474 fixed the Lint problems.
      
      Closes #5777.
      Closes #15175.
      18e53386
    • Roland Senn's avatar
      GHCi :complete command for operators: Fix spaceless cases of #10576. · 793dcb3d
      Roland Senn authored
      When separating operators from identifiers in a `:complete` command
      take advantage from the different character sets of the two items:
      * operators contain only specialSymbol characters.
      * Identifiers don't contain specialSymbol characters, with the exception of dots.
      793dcb3d
    • Joachim Breitner's avatar
      Always set `safeInferred`, not only when it turns `False` · f1362008
      Joachim Breitner authored
      previously, `safeFlagCheck` would be happy to switch the `safeFlag` to
      `False`, but not the other way around. This meant that after
      
          :set -XGeneralizedNewtypeDeriving
          :set -XNoGeneralizedNewtypeDeriving
      
      in GHCi all loaded files would be still be infered as unsafe.
      
      This fixes #19243.
      
      This is a corner case, but somewhat relevant once ghci by default starts
      with `GeneralizedNewtypeDeriving` on (due to GHC2021).
      f1362008
    • Sylvain Henry's avatar
      Refactor Logger · 8e2f85f6
      Sylvain Henry authored
      Before this patch, the only way to override GHC's default logging
      behavior was to set `log_action`, `dump_action` and `trace_action`
      fields in DynFlags. This patch introduces a new Logger abstraction and
      stores it in HscEnv instead.
      
      This is part of #17957 (avoid storing state in DynFlags). DynFlags are
      duplicated and updated per-module (because of OPTIONS_GHC pragma), so
      we shouldn't store global state in them.
      
      This patch also fixes a race in parallel "--make" mode which updated
      the `generatedDumps` IORef concurrently.
      
      Bump haddock submodule
      
      The increase in MultilayerModules is tracked in #19293.
      
      Metric Increase:
          MultiLayerModules
      8e2f85f6
  3. 09 Feb, 2021 3 commits
  4. 06 Feb, 2021 5 commits
  5. 30 Jan, 2021 2 commits
    • Sylvain Henry's avatar
      Fix -dynamic-too with wired-in modules (#19264) · a3d995fa
      Sylvain Henry authored
      See T19264 for a tricky corner case when explicitly importing
      GHC.Num.BigNat and another module. With -dynamic-too, the FinderCache
      contains paths for non-dynamic interfaces so they must be loaded first,
      which is usually the case, except for some interfaces loaded in the
      backend (e.g. in CorePrep).
      
      So we must run the backend for the non-dynamic way first for
      -dynamic-too to work as it is but I broke this invariant in
      c85f4928 by mistakenly making the
      backend run for the dynamic way first.
      a3d995fa
    • Simon Peyton Jones's avatar
      Zonk the returned kind in tcFamTyPats · 69cab37a
      Simon Peyton Jones authored
      The motivation is given in Note [tcFamTyPats: zonking the result kind].
      
      Fixes #19250  --  the fix is easy.
      69cab37a
  6. 29 Jan, 2021 1 commit
  7. 27 Jan, 2021 7 commits
    • Sylvain Henry's avatar
      Fix spurious failures of T16916 on CI (#16966) · 9c87f97e
      Sylvain Henry authored
      * disable idle GC which has a big impact on time measures
      
      * use average measures (before and after event registration)
      
      * use warmup measures (for some reason the first measure of a batch
        seems to be often quite different from the others)
      
      * drop the division by monotonic clock time: this clock is impacted by
        the load of the runner.  We only want to measure the time spent in the
        RTS while the mutator is idle so I don't understand why it was used.
      9c87f97e
    • Richard Eisenberg's avatar
      Remove some redundant validity checks. · 189efc39
      Richard Eisenberg authored
      This commit also consolidates documentation in the user
      manual around UndecidableSuperClasses, UndecidableInstances,
      and FlexibleContexts.
      
      Close #19186.
      Close #19187.
      
      Test case: typecheck/should_compile/T19186,
      typecheck/should_fail/T19187{,a}
      189efc39
    • Adam Gundry's avatar
      Add regression test for #11228 · 2f689a8b
      Adam Gundry authored
      2f689a8b
    • Hécate Moonlight's avatar
      08fba093
    • Ben Gamari's avatar
      Add instances for GHC.Tuple.Solo · 5d6009a8
      Ben Gamari authored
      The `Applicative` instance is the most important one (for
      array/vector/sequence indexing purposes), but it deserves
      all the usual ones.
      
      T12545 does silly 1% wibbles both ways, it seems, maybe depending
      on architecture.
      
      Metric Increase:
          T12545
      
      Metric Decrease:
          T12545
      5d6009a8
    • Aaron Allen's avatar
      Add additional context to :doc output (#19055) · 93ae0e2a
      Aaron Allen authored
      With this change, the type/kind of an object as well as it's category
      and definition site are added to the output of the :doc command for each
      object matching the argument string.
      93ae0e2a
    • Matthew Pickering's avatar
      Deprecate -h flag · 92573883
      Matthew Pickering authored
      It is confusing that it defaults to two different things depending on
      whether we are in the profiling way or not.
      
      Use -hc if you have a profiling build
      Use -hT if you have a normal build
      
      Fixes #19031
      92573883
  8. 24 Jan, 2021 2 commits
    • John Ericson's avatar
      Track the dependencies of `GHC.Hs.Expr.Types` · 8ec6d62a
      John Ericson authored
      Thery is still, in my view, far too numerous, but I believe this won't
      be too hard to improve upon. At the very lease, we can always add more
      extension points!
      8ec6d62a
    • John Ericson's avatar
      Separate AST from GhcPass (#18936) · 81f06655
      John Ericson authored
      ```-------------
      What:
      
      There are two splits.
      
      The first spit is:
      
       - `Language.Haskell.Syntax.Extension`
       - `GHC.Hs.Extension`
      
      where the former now just contains helpers like `NoExtCon` and all the
      families, and the latter is everything having to do with `GhcPass`.
      
      The second split is:
      
       - `Language.Haskell.Syntax.<mod>`
       - `GHC.Hs.<mod>`
      
      Where the former contains all the data definitions, and the few helpers
      that don't use `GhcPass`, and the latter contains everything else. The
      second modules also reexport the former.
      ```
      
      -------------
      Why:
      
      See the issue for more details, but in short answer is we're trying to
      grasp at the modularity TTG is supposed to offer, after a long time of
      mainly just getting the safety benefits of more complete pattern
      matching on the AST.
      
      Now, we have an AST datatype which, without `GhcPass` is decently
      stripped of GHC-specific concerns. Whereas before, not was it
      GHC-specific, it was aware of all the GHC phases despite the
      parameterization, with the instances and parametric data structure
      side-by-side.
      
      For what it's worth there are also some smaller, imminent benefits:
      
      - The latter change also splits a strongly connected component in two,
        since none of the `Language.Haskell.Syntax.*` modules import the older
        ones.
      
      - A few TTG violations (Using GhcPass directly in the AST) in `Expr` are
        now more explicitly accounted for with new type families to provide the
        necessary indirection.
      
      -----------------
      Future work:
      
      - I don't see why all the type families should live in
        `Language.Haskell.Syntax.Extension`. That seems anti-modular for
        little benefit. All the ones used just once can be moved next to the
        AST type they serve as an extension point for.
      
      - Decide what to do with the `Outputable` instances. Some of these are
        no orphans because they referred to `GhcPass`, and had to be moved. I
        think the types could be generalized so they don't refer to `GhcPass`
        and therefore can be moved back, but having gotten flak for increasing
        the size and complexity types when generalizing before, I did *not*
        want to do this.
      
      - We should triage the remaining contents of `GHC.Hs.<mod>`. The
        renaming helpers are somewhat odd for needing `GhcPass`. We might
        consider if they are a) in fact only needed by one phase b) can be
        generalized to be non-GhcPass-specific (e.g. take a callback rather
        than GADT-match with `IsPass`) and then they can live in
        `Language.Haskell.Syntax.<mod>`.
      
      For more details, see
      https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow
      
      Bumps Haddock submodule
      81f06655
  9. 23 Jan, 2021 3 commits
    • Sylvain Henry's avatar
      Bignum: add Natural constant folding rules (#15821) · 773e2828
      Sylvain Henry authored
      * Implement constant folding rules for Natural (similar to Integer ones)
      
      * Add mkCoreUbxSum helper in GHC.Core.Make
      
      * Remove naturalTo/FromInt
      
        We now only provide `naturalTo/FromWord` as
        the semantics is clear (truncate/zero-extend). For Int we have to deal
        with negative numbers (throw an exception? convert to Word
        beforehand?) so we leave the decision about what to do to the caller.
      
        Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#,
        etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#`
        (for example).
      
      * Replaced a few `()` with `(# #)`
      773e2828
    • koz_'s avatar
      Implement #15993 · 8f610e52
      koz_ authored
      8f610e52
    • Richard Eisenberg's avatar
      Make matchableGivens more reliably correct. · 8fd855f0
      Richard Eisenberg authored
      This has two fixes:
      
      1. Take TyVarTvs into account in matchableGivens. This
         fixes #19106.
      
      2. Don't allow unifying alpha ~ Maybe alpha. This fixes
         #19107.
      
      This patch also removes a redundant Note and redirects
      references to a better replacement.
      
      Also some refactoring/improvements around the BindFun
      in the pure unifier, which now can take the RHS type
      into account.
      
      Close #19106.
      Close #19107.
      
      Test case: partial-sigs/should_compile/T19106,
                 typecheck/should_compile/T19107
      8fd855f0
  10. 22 Jan, 2021 3 commits
    • Sylvain Henry's avatar
      Core: introduce Alt/AnnAlt/IfaceAlt datatypes · 957b5376
      Sylvain Henry authored
      Alt, AnnAlt and IfaceAlt were using triples. This patch makes them use
      dedicated types so that we can try to make some fields strict (for
      example) in the future.
      957b5376
    • Sylvain Henry's avatar
      Enhance Data instance generation · 887eb6ec
      Sylvain Henry authored
      Use `mkConstrTag` to explicitly pass the constructor tag instead of
      using `mkConstr` which queries the tag at runtime by querying the index
      of the constructor name (a string) in the list of constructor names.
      
      Perf improvement:
      
          T16577(normal) ghc/alloc 11325573876.0  9249786992.0 -18.3% GOOD
      
      Thanks to @sgraf812 for suggesting an additional list fusion fix during
      reviews.
      
      Metric Decrease:
          T16577
      887eb6ec
    • John Ericson's avatar
      Test constant folding for sized types · 6fbfde95
      John Ericson authored
      6fbfde95