Skip to content
Snippets Groups Projects
  1. Feb 14, 2024
    • Alan Zimmerman's avatar
      EPA: Move EpAnn out of extension points · 0e01e1db
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Leaving a few that are too tricky, maybe some other time.
      
      Also
       - remove some unneeded helpers from Parser.y
       - reduce allocations with strictness annotations
      
      Updates haddock submodule
      
      Metric Decrease:
          parsing001
      0e01e1db
  2. Feb 03, 2024
    • Apoorv Ingle's avatar
      Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. · 5ff7cc26
      Apoorv Ingle authored
      - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206
      
      - The change is detailed in
        - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`
        - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
               expains the rational of doing expansions in type checker as opposed to in the renamer
      
      - Adds new datatypes:
        - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier
          1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
          2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
      
        - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
          This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`
      
        - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`
      
      - Ensures warnings such as
        1. Pattern match checks
        2. Failable patterns
        3. non-() return in body statements are preserved
      
      - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker`
      
      - Testcases:
        * T18324 T20020 T23147 T22788 T15598 T22086
        * T23147b (error message check),
        * DoubleMatch (match inside a match for pmc check)
        * pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
        * Simple-rec (rec statements inside do statment)
        * T22788 (code snippet from #22788)
        * DoExpanion1 (Error messages for body statments)
        * DoExpansion2 (Error messages for bind statements)
        * DoExpansion3 (Error messages for let statements)
      
      Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass
      
      Metric Increase 'compile_time/bytes allocated':
          T9020
      
      The testcase is a pathalogical example of a `do`-block with many statements that do nothing.
      Given that we are expanding the statements into function binds, we will have to bear
      a (small) 2% cost upfront in the compiler to unroll the statements.
      5ff7cc26
    • Matthew Craven's avatar
      Bump bytestring submodule to something closer to 0.12.1 · 27020458
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      ...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c
      (which reworks unaligned writes in Builder) and the stuff in
      https://github.com/haskell/bytestring/pull/631 can see wider testing.
      
      The less-terrible code for unaligned writes used in Builder on
      hosts not known to be ulaigned-friendly also takes less effort
      for GHC to compile, resulting in a metric decrease for T21839c
      on some platforms.
      
      The metric increase on T21839r is caused by the unrelated commit
      750dac33465e7b59100698a330b44de7049a345c.  It perhaps warrants
      further analysis and discussion (see #23822) but is not critical.
      
      Metric Decrease:
      T21839c
      Metric Increase:
      T21839r
      27020458
  3. Dec 14, 2023
  4. Dec 13, 2023
  5. Nov 27, 2023
    • Alan Zimmerman's avatar
      EPA: Remove SrcSpanAnn · 4e5ff6a4
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Now that we only have a single constructor for EpAnn, And it uses a
      SrcSpan for its location, we can do away with SrcSpanAnn completely.
      It only existed to wrap the original SrcSpan in a location, and
      provide a place for the exact print annotation.
      
      For darwin only:
      Metric Increase:
          MultiLayerModulesTH_OneShot
      
      Updates haddock submodule
      4e5ff6a4
  6. Nov 26, 2023
    • Alan Zimmerman's avatar
      EPA: Remove EpAnnNotUsed · 7902ebf8
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      We no longer need the EpAnnNotUsed constructor for EpAnn, as we can
      represent an unused annotation with an anchor having a EpaDelta of
      zero, and empty comments and annotations.
      
      This simplifies code handling annotations considerably.
      
      Updates haddock submodule
      
      Metric Increase:
          parsing001
      7902ebf8
  7. Nov 12, 2023
    • Alan Zimmerman's avatar
      EPA: Replace Anchor with EpaLocation · 3f0036ec
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      An Anchor has a location and an operation, which is either that it is
      unchanged or that it has moved with a DeltaPos
      
          data Anchor = Anchor { anchor :: RealSrcSpan
                               , anchor_op :: AnchorOperation }
      
      An EpaLocation also has either a location or a DeltaPos
      
          data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
                           | EpaDelta !DeltaPos ![LEpaComment]
      
      Now that we do not care about always having a location in the anchor,
      we remove Anchor and replace it with EpaLocation
      
      We do this with a type alias initially, to ease the transition.
      The alias will be removed in time.
      
      We also have helpers to reconstruct the AnchorOperation from an
      EpaLocation. This is also temporary.
      
      Updates Haddock submodule
      3f0036ec
  8. Nov 02, 2023
    • Alan Zimmerman's avatar
      EPA: Use full range for Anchor · 81fb8885
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This change requires a series of related changes, which must all land
      at the same time, otherwise all the EPA tests break.
      
      * Use the current Anchor end as prior end
      
        Use the original anchor location end as the source of truth for
        calculating print deltas.
      
        This allows original spacing to apply in most cases, only changed
        AST items need initial delta positions.
      
      * Add DArrow to TrailingAnn
      
      * EPA Introduce HasTrailing in ExactPrint
      
         Use [TrailingAnn] in enterAnn and remove it from
         ExactPrint (LocatedN RdrName)
      
      * In HsDo, put TrailingAnns at top of LastStmt
      
      * EPA: do not convert comments to deltas when balancing.
      
      * EPA: deal with fallout from getMonoBind
      
      * EPA fix captureLineSpacing
      
      * EPA print any comments in the span before exiting it
      
      * EPA: Add comments to AnchorOperation
      
      * EPA: remove AnnEofComment, it is no longer used
      
      Updates Haddock submodule
      81fb8885
  9. Oct 24, 2023
    • Cheng Shao's avatar
      testsuite: increase timeout of ghc-api tests for wasm32 · 07ab5cc1
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      ghc-api tests for wasm32 are more likely to timeout due to the large
      wasm module sizes, especially when testing with wasm native tail
      calls, given wasmtime's handling of tail call opcodes are suboptimal
      at the moment. It makes sense to increase timeout specifically for
      these tests on wasm32. This doesn't affect other targets, and for
      wasm32 we don't increase timeout for all tests, so not to risk letting
      major performance regressions slip through the testsuite.
      07ab5cc1
  10. Sep 19, 2023
  11. Sep 12, 2023
    • Matthew Pickering's avatar
      Add -Winconsistent-flags warning · 21a906c2
      Matthew Pickering authored and Krzysztof Gogolewski's avatar Krzysztof Gogolewski committed
      The warning fires when inconsistent command line flags are passed.
      
      For example:
      
      * -dynamic-too and -dynamic
      * -dynamic-too on windows
      * -O and --interactive
      * etc
      
      This is on by default and allows users to control whether the warning is
      displayed and whether it should be an error or not.
      
      Fixes #22572
      21a906c2
  12. Aug 30, 2023
  13. Aug 22, 2023
    • Alan Zimmerman's avatar
      EPA: Use Introduce [DeclTag] in AnnSortKey · ab40aa52
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The AnnSortKey is used to keep track of the order of declarations for
      printing when the container has split them apart.
      
      This applies to HsValBinds and ClassDecl, ClsInstDecl.
      
      When making modifications to the list of declarations, the new order
      must be captured for when it must be printed. For each list of
      declarations (binds and sigs for a HsValBind) we can just store the
      list in order.
      
      To recreate the list when printing, we must merge them, and this is
      what the AnnSortKey records. It used to be indexed by SrcSpan, we now
      simply index by a marker as to which list to take the next item from.
      ab40aa52
  14. Aug 21, 2023
  15. Aug 04, 2023
    • Matthew Craven's avatar
      Adjust and clarify handling of primop effects · 8ba20b21
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      Fixes #17900; fixes #20195.
      
      The existing "can_fail" and "has_side_effects" primop attributes
      that previously governed this were used in inconsistent and
      confusingly-documented ways, especially with regard to raising
      exceptions.  This patch replaces them with a single "effect"
      attribute, which has four possible values: NoEffect, CanFail,
      ThrowsException, and ReadWriteEffect.  These are described in
      Note [Classifying primop effects].
      
      A substantial amount of related documentation has been re-drafted
      for clarity and accuracy.
      
      In the process of making this attribute format change for literally
      every primop, several existing mis-classifications were detected and
      corrected.  One of these mis-classifications was tagToEnum#, which
      is now considered CanFail; this particular fix is known to cause a
      regression in performance for derived Enum instances.  (See #23782.)
      Fixing this is left as future work.
      
      New primop attributes "cheap" and "work_free" were also added,
      and used in the corresponding parts of GHC.Core.Utils.
      
      In view of their actual meaning and uses, `primOpOkForSideEffects`
      and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
      and `exprOkToDiscard`, respectively.
      
      Metric Increase:
          T21839c
      8ba20b21
  16. Jul 18, 2023
    • sheaf's avatar
      Re-instate -Wincomplete-record-updates · df706de3
      sheaf authored and Marge Bot's avatar Marge Bot committed
      Commit e74fc066 refactored the handling of record updates to use
      the HsExpanded mechanism. This meant that the pattern matching inherent
      to a record update was considered to be "generated code", and thus we
      stopped emitting "incomplete record update" warnings entirely.
      
      This commit changes the "data Origin = Source | Generated" datatype,
      adding a field to the Generated constructor to indicate whether we
      still want to perform pattern-match checking. We also have to do a bit
      of plumbing with HsCase, to record that the HsCase arose from an
      HsExpansion of a RecUpd, so that the error message continues to mention
      record updates as opposed to a generic "incomplete pattern matches in case"
      error.
      
      Finally, this patch also changes the way we handle inaccessible code
      warnings. Commit e74fc066 was also a regression in this regard, as we
      were emitting "inaccessible code" warnings for case statements spuriously
      generated when desugaring a record update (remember: the desugaring mechanism
      happens before typechecking; it thus can't take into account e.g. GADT information
      in order to decide which constructors to include in the RHS of the desugaring
      of the record update).
      We fix this by changing the mechanism through which we disable inaccessible
      code warnings: we now check whether we are in generated code in
      GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
      emit inaccessible code warnings.
      
      Fixes #23520
      Updates haddock submodule, to avoid incomplete record update warnings
      df706de3
  17. Jul 06, 2023
  18. Jun 15, 2023
  19. Jun 13, 2023
  20. May 27, 2023
    • Alan Zimmerman's avatar
      EPA: Better fix for #22919 · 69fdbece
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The original fix for #22919 simply removed the ability to match up
      prior comments with the first declaration in the file.
      
      Restore it, but add a check that the comment is on a single line, by
      ensuring that it comes immediately prior to the next thing (comment or
      start of declaration), and that the token preceding it is not on the
      same line.
      
      closes #22919
      69fdbece
  21. May 26, 2023
    • Matthew Pickering's avatar
      error messages: Don't display ghci specific hints for missing packages · 34b44f7d
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Tickets like #22884 suggest that it is confusing that GHC used on the
      command line can suggest options which only work in GHCi.
      
      This ticket uses the error message infrastructure to override certain
      error messages which displayed GHCi specific information so that this
      information is only showed when using GHCi.
      
      The main annoyance is that we mostly want to display errors in the same
      way as before, but with some additional information. This means that the
      error rendering code has to be exported from the Iface/Errors/Ppr.hs
      module.
      
      I am unsure about whether the approach taken here is the best or most
      maintainable solution.
      
      Fixes #22884
      34b44f7d
  22. May 19, 2023
  23. May 18, 2023
  24. May 16, 2023
    • Zubin's avatar
      compiler: Use compact representation for SourceText · 90e69d5d
      Zubin authored and Marge Bot's avatar Marge Bot committed
      SourceText is serialized along with INLINE pragmas into interface files. Many of
      these SourceTexts are identical, for example "{-# INLINE#". When deserialized,
      each such SourceText was previously expanded out into a [Char], which is highly
      wasteful of memory, and each such instance of the text would allocate an
      independent list with its contents as deserializing breaks any sharing that might
      have existed.
      
      Instead, we use a `FastString` to represent these, so that each instance unique
      text will be interned and stored in a memory efficient manner.
      90e69d5d
  25. Apr 27, 2023
    • Cheng Shao's avatar
      testsuite: add the req_process predicate · ce580426
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds the req_process predicate to the testsuite to assert
      the platform has a process model, also marking tests that involve
      spawning processes as req_process. Also bumps hpc & process submodule.
      ce580426
  26. Apr 26, 2023
    • Alan Zimmerman's avatar
      EPA: Use ExplicitBraces only in HsModule · 052e2bb6
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      !9018 brought in exact print annotations in LayoutInfo for open and
      close braces at the top level.
      
      But it retained them in the HsModule annotations too.
      
      Remove the originals, so exact printing uses LayoutInfo
      052e2bb6
  27. Apr 25, 2023
  28. Apr 18, 2023
    • Matthew Pickering's avatar
      Convert interface file loading errors into proper diagnostics · 5e1d33d7
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This patch converts all the errors to do with loading interface files
      into proper structured diagnostics.
      
      * DriverMessage: Sometimes in the driver we attempt to load an interface
        file so we embed the IfaceMessage into the DriverMessage.
      * TcRnMessage: Most the time we are loading interface files during
        typechecking, so we embed the IfaceMessage
      
      This patch also removes the TcRnInterfaceLookupError constructor which
      is superceded by the IfaceMessage, which is now structured compared to
      just storing an SDoc before.
      5e1d33d7
  29. Mar 30, 2023
  30. Mar 21, 2023
    • Andrei Borzenkov's avatar
      Rename () into Unit, (,,...,,) into Tuple<n> (#21294) · a13affce
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      
      This patch implements a part of GHC Proposal #475.
      The key change is in GHC.Tuple.Prim:
      
        - data () = ()
        - data (a,b) = (a,b)
        - data (a,b,c) = (a,b,c)
        ...
        + data Unit = ()
        + data Tuple2 a b = (a,b)
        + data Tuple3 a b c = (a,b,c)
        ...
      
      And the rest of the patch makes sure that Unit and Tuple<n>
      are pretty-printed as () and (,,...,,) in various contexts.
      
      Updates the haddock submodule.
      
      Co-authored-by: default avatarVladislav Zavialov <vlad.z.4096@gmail.com>
      a13affce
  31. Feb 08, 2023
  32. Feb 06, 2023
  33. Jan 05, 2023
    • Alan Zimmerman's avatar
      EPA: Do not collect comments from end of file · 22bb8998
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      In Parser.y semis1 production triggers for the virtual semi at the end
      of the file. This is detected by it being zero length.
      
      In this case, do not extend the span being used to gather comments, so
      any final comments are allocated at the module level instead.
      22bb8998
  34. Dec 23, 2022
  35. Dec 14, 2022
  36. Dec 09, 2022
    • Krzysztof Gogolewski's avatar
      Fixes around primitive literals · b0cc2fcf
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      * The SourceText of primitive characters 'a'# did not include
        the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#.
        We can now remove the function pp_st_suffix, which was a hack
        to add the # back.
      * Negative primitive literals shouldn't use parentheses, as described in
        Note [Printing of literals in Core]. Added a testcase to T14681.
      b0cc2fcf
  37. Nov 29, 2022
  38. Oct 18, 2022
    • Matthew Pickering's avatar
      Allow configuration of error message printing · e1bbd368
      Matthew Pickering authored and sheaf's avatar sheaf committed
      This MR implements the idea of #21731 that the printing of a diagnostic
      method should be configurable at the printing time.
      
      The interface of the `Diagnostic` class is modified from:
      
      ```
      class Diagnostic a where
        diagnosticMessage :: a -> DecoratedSDoc
        diagnosticReason  :: a -> DiagnosticReason
        diagnosticHints   :: a -> [GhcHint]
      ```
      
      to
      
      ```
      class Diagnostic a where
        type DiagnosticOpts a
        defaultDiagnosticOpts :: DiagnosticOpts a
        diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
        diagnosticReason  :: a -> DiagnosticReason
        diagnosticHints   :: a -> [GhcHint]
      ```
      
      and so each `Diagnostic` can implement their own configuration record
      which can then be supplied by a client in order to dictate how to print
      out the error message.
      
      At the moment this only allows us to implement #21722 nicely but in
      future it is more natural to separate the configuration of how much
      information we put into an error message and how much we decide to print
      out of it.
      
      Updates Haddock submodule
      e1bbd368
Loading