Skip to content
Snippets Groups Projects
  1. Feb 27, 2021
  2. Feb 26, 2021
    • Ryan Scott's avatar
      Fix #19363 by using pprName' {Applied,Infix} in the right places · 8d1fb46d
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      It was revealed in #19363 that the Template Haskell pretty-printer implemented
      in `Language.Haskell.TH.Ppr` did not pretty-print infix names or symbolic names
      correctly in certain situations, such as in data constructor declarations or
      fixity declarations. Easily fixed by using `pprName' Applied` (which always
      parenthesizes symbolic names in prefix position) or `pprName' Infix` (which
      always surrounds alphanumeric names with backticks in infix position) in the
      right spots.
      
      Fixes #19363.
      8d1fb46d
    • Adam Gundry's avatar
      Implement -Wambiguous-fields · 80eda911
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      Fixes #18966. Adds a new warning -Wambiguous-fields for uses of field selectors
      or record updates that will be rejected in the future, when the DuplicateRecordFields
      extension is simplified per https://github.com/ghc-proposals/ghc-proposals/pull/366.
      80eda911
  3. Feb 24, 2021
  4. Feb 23, 2021
  5. Feb 22, 2021
  6. Feb 19, 2021
    • Simon Peyton Jones's avatar
      Improve handling of overloaded labels, literals, lists etc · 4196969c
      Simon Peyton Jones authored
      When implementing Quick Look I'd failed to remember that overloaded
      labels, like #foo, should be treated as a "head", so that they can be
      instantiated with Visible Type Application. This caused #19154.
      
      A very similar ticket covers overloaded literals: #19167.
      
      This patch fixes both problems, but (annoyingly, albeit temporarily)
      in two different ways.
      
      Overloaded labels
      
      I dealt with overloaded labels by buying fully into the
      Rebindable Syntax approach described in GHC.Hs.Expr
      Note [Rebindable syntax and HsExpansion].
      
      There is a good overview in GHC.Rename.Expr
      Note [Handling overloaded and rebindable constructs].
      That module contains much of the payload for this patch.
      
      Specifically:
      
      * Overloaded labels are expanded in the renamer, fixing #19154.
        See Note [Overloaded labels] in GHC.Rename.Expr.
      
      * Left and right sections used to have special code paths in the
        typechecker and desugarer.  Now we just expand them in the
        renamer. This is harder than it sounds.  See GHC.Rename.Expr
        Note [Left and right sections].
      
      * Infix operator applications are expanded in the typechecker,
        specifically in GHC.Tc.Gen.App.splitHsApps.  See
        Note [Desugar OpApp in the typechecker] in that module
      
      * ExplicitLists are expanded in the renamer, when (and only when)
        OverloadedLists is on.
      
      * HsIf is expanded in the renamer when (and only when) RebindableSyntax
        is on.  Reason: the coverage checker treats HsIf specially.  Maybe
        we could instead expand it unconditionally, and fix up the coverage
        checker, but I did not attempt that.
      
      Overloaded literals
      
      Overloaded literals, like numbers (3, 4.2) and strings with
      OverloadedStrings, were not working correctly with explicit type
      applications (see #19167).  Ideally I'd also expand them in the
      renamer, like the stuff above, but I drew back on that because they
      can occur in HsPat as well, and I did not want to to do the HsExpanded
      thing for patterns.
      
      But they *can* now be the "head" of an application in the typechecker,
      and hence something like ("foo" @T) works now.  See
      GHC.Tc.Gen.Head.tcInferOverLit.  It's also done a bit more elegantly,
      rather than by constructing a new HsExpr and re-invoking the
      typechecker. There is some refactoring around tcShortCutLit.
      
      Ultimately there is more to do here, following the Rebindable Syntax
      story.
      
      There are a lot of knock-on effects:
      
      * HsOverLabel and ExplicitList no longer need funny (Maybe SyntaxExpr)
        fields to support rebindable syntax -- good!
      
      * HsOverLabel, OpApp, SectionL, SectionR all become impossible in the
        output of the typecheker, GhcTc; so we set their extension fields to
        Void. See GHC.Hs.Expr Note [Constructor cannot occur]
      
      * Template Haskell quotes for HsExpanded is a bit tricky.  See
        Note [Quotation and rebindable syntax] in GHC.HsToCore.Quote.
      
      * In GHC.HsToCore.Match.viewLExprEq, which groups equal HsExprs for the
        purpose of pattern-match overlap checking, I found that dictionary
        evidence for the same type could have two different names.  Easily
        fixed by comparing types not names.
      
      * I did quite a bit of annoying fiddling around in GHC.Tc.Gen.Head and
        GHC.Tc.Gen.App to get error message locations and contexts right,
        esp in splitHsApps, and the HsExprArg type.  Tiresome and not very
        illuminating.  But at least the tricky, higher order, Rebuilder
        function is gone.
      
      * Some refactoring in GHC.Tc.Utils.Monad around contexts and locations
        for rebindable syntax.
      
      * Incidentally fixes #19346, because we now print renamed, rather than
        typechecked, syntax in error mesages about applications.
      
      The commit removes the vestigial module GHC.Builtin.RebindableNames,
      and thus triggers a 2.4% metric decrease for test MultiLayerModules
      (#19293).
      
      Metric Decrease:
          MultiLayerModules
          T12545
      4196969c
  7. Feb 18, 2021
    • Matthew Pickering's avatar
      Test Driver: Tweak interval of test reporting · f78f001c
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Rather than just display every 100 tests, work out how many to display
      based on the total number of tests. This improves the experience when
      running a small number of tests.
      
      For [0..100] - Report every test
          [100..1000] - Report every 10 tests
          [1000..10000] - Report every 100 tests
          and so on..
      f78f001c
    • Simon Peyton Jones's avatar
      Improve specialisation for imported functions · 60ed2a65
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      At a SPECIALSE pragma for an imported Id, we used to check that
      it was marked INLINABLE.  But that turns out to interact badly with
      worker/wrapper: see Note [Worker-wrapper for INLINABLE functions] in
      GHC.Core.Opt.WorkWrap.
      
      So this small patch instead simply tests that we have an unfolding
      for the function; see Note [SPECIALISE pragmas for imported Ids]
      in GHC.Tc.Gen.Sig.
      
      Fixes #19246
      60ed2a65
  8. Feb 17, 2021
  9. Feb 16, 2021
    • Ryan Scott's avatar
      Parse symbolic names in ANN type correctly with otycon · a04179e7
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      
      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: default avatarSimon Hafner <hafnersimon@gmail.com>
      Co-authored-by: default avatarFumiaki Kinoshita <fumiexcel@gmail.com>
      2521b041
  10. Feb 14, 2021
    • 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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      74fec146
    • Sylvain Henry's avatar
      Bignum: fix bogus rewrite rule (#19345) · 5e71dd33
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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 and Marge Bot's avatar Marge Bot committed
      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
  11. Feb 09, 2021
  12. Feb 06, 2021
Loading