1. 09 Oct, 2020 1 commit
    • Alan Zimmerman's avatar
      ApiAnnotations : preserve parens in GADTs · 36787bba
      Alan Zimmerman authored
      A cleanup in 7f418acf61e accidentally discarded some parens in
      ConDeclGADT.
      
      Make sure these stay in the AST in a usable format.
      
      Also ensure the AnnLolly does not get lost in a GADT.
      36787bba
  2. 01 Oct, 2020 2 commits
    • Sylvain Henry's avatar
    • Sylvain Henry's avatar
      Use ADTs for parser errors/warnings · a5aaceec
      Sylvain Henry authored
      Haskell and Cmm parsers/lexers now report errors and warnings using ADTs
      defined in GHC.Parser.Errors. They can be printed using functions in
      GHC.Parser.Errors.Ppr.
      
      Some of the errors provide hints with a separate ADT (e.g. to suggest to
      turn on some extension). For now, however, hints are not consistent
      across all messages. For example some errors contain the hints in the
      main message. I didn't want to change any message with this patch. I
      expect these changes to be discussed and implemented later.
      
      Surprisingly, this patch enhances performance. On CI
      (x86_64/deb9/hadrian, ghc/alloc):
      
         parsing001         -11.5%
         T13719             -2.7%
         MultiLayerModules  -3.5%
         Naperian           -3.1%
      
      Bump haddock submodule
      
      Metric Decrease:
          MultiLayerModules
          Naperian
          T13719
          parsing001
      a5aaceec
  3. 29 Sep, 2020 2 commits
  4. 09 Sep, 2020 1 commit
    • Alan Zimmerman's avatar
      Remove GENERATED pragma, as it is not being used · 7911d0d9
      Alan Zimmerman authored
      @alanz pointed out on ghc-devs that the payload of this pragma does
      not appear to be used anywhere.
      
      I (@bgamari) did some digging and traced the pragma's addition back to
      d386e0d2 (way back in 2006!).
      
      It appears that it was intended to be used by code generators for use
      in informing the code coveraging checker about generated code
      provenance. When it was added it used the pragma's "payload" fields as
      source location information to build an "ExternalBox". However, it
      looks like this was dropped a year later in 55a5d8d9.  At this point
      it seems like the pragma serves no useful purpose.
      
      Given that it also is not documented, I think we should remove it.
      
      Updates haddock submodule
      
      Closes #18639
      7911d0d9
  5. 13 Aug, 2020 1 commit
    • Sylvain Henry's avatar
      Add HomeUnit type · ffc0d578
      Sylvain Henry authored
      Since Backpack the "home unit" is much more involved than what it was
      before (just an identifier obtained with `-this-unit-id`). Now it is
      used in conjunction with `-component-id` and `-instantiated-with` to
      configure module instantiations and to detect if we are type-checking an
      indefinite unit or compiling a definite one.
      
      This patch introduces a new HomeUnit datatype which is much easier to
      understand. Moreover to make GHC support several packages in the same
      instances, we will need to handle several HomeUnits so having a
      dedicated (documented) type is helpful.
      
      Finally in #14335 we will also need to handle the case where we have no
      HomeUnit at all because we are only loading existing interfaces for
      plugins which live in a different space compared to units used to
      produce target code. Several functions will have to be refactored to
      accept "Maybe HomeUnit" parameters instead of implicitly querying the
      HomeUnit fields in DynFlags. Having a dedicated type will make this
      easier.
      
      Bump had...
      ffc0d578
  6. 12 Aug, 2020 1 commit
    • Sylvain Henry's avatar
      DynFlags: disentangle Outputable · accbc242
      Sylvain Henry authored
      - put panic related functions into GHC.Utils.Panic
      - put trace related functions using DynFlags in GHC.Driver.Ppr
      
      One step closer making Outputable fully independent of DynFlags.
      
      Bump haddock submodule
      accbc242
  7. 27 Jul, 2020 1 commit
    • Vladislav Zavialov's avatar
      Improve NegativeLiterals (#18022, GHC Proposal #344) · aee45d9e
      Vladislav Zavialov authored
      Before this patch, NegativeLiterals used to parse x-1 as x (-1).
      
      This may not be what the user expects, and now it is fixed:
      x-1 is parsed as (-) x 1.
      
      We achieve this by the following requirement:
      
        * When lexing a negative literal,
          it must not be preceded by a 'closing token'.
      
      This also applies to unboxed literals, e.g. -1#.
      
      See GHC Proposal #229 for the definition of a closing token.
      
      A nice consequence of this change is that -XNegativeLiterals becomes a
      subset of -XLexicalNegation. In other words, enabling both of those
      extensions has the same effect as enabling -XLexicalNegation alone.
      aee45d9e
  8. 21 Jul, 2020 1 commit
    • Vladislav Zavialov's avatar
      Accumulate Haddock comments in P (#17544, #17561, #8944) · 19e80b9a
      Vladislav Zavialov authored
      Haddock comments are, first and foremost, comments. It's very annoying
      to incorporate them into the grammar. We can take advantage of an
      important property: adding a Haddock comment does not change the parse
      tree in any way other than wrapping some nodes in HsDocTy and the like
      (and if it does, that's a bug).
      
      This patch implements the following:
      
      * Accumulate Haddock comments with their locations in the P monad.
        This is handled in the lexer.
      
      * After parsing, do a pass over the AST to associate Haddock comments
        with AST nodes using location info.
      
      * Report the leftover comments to the user as a warning (-Winvalid-haddock).
      19e80b9a
  9. 18 Jul, 2020 1 commit
  10. 12 Jul, 2020 1 commit
    • Andreas Klebinger's avatar
      Give Uniq[D]FM a phantom type for its key. · c4de6a7a
      Andreas Klebinger authored
      This fixes #17667 and should help to avoid such issues going forward.
      
      The changes are mostly mechanical in nature. With two notable
      exceptions.
      
      * The register allocator.
      
        The register allocator references registers by distinct uniques.
        However they come from the types of VirtualReg, Reg or Unique in
        various places. As a result we sometimes cast the key type of the
        map and use functions which operate on the now typed map but take
        a raw Unique as actual key. The logic itself has not changed it
        just becomes obvious where we do so now.
      
      * <Type>Env Modules.
      
      As an example a ClassEnv is currently queried using the types `Class`,
      `Name`, and `TyCon`. This is safe since for a distinct class value all
      these expressions give the same unique.
      
          getUnique cls
          getUnique (classTyCon cls)
          getUnique (className cls)
          getUnique (tcName $ classTyCon cls)
      
      This is for the most part contained within the modules defining the
      interface. However it requires us to play dirty when we are given a
      `Name` to lookup in a `UniqFM Class a` map. But again the logic did
      not change and it's for the most part hidden behind the Env Module.
      
      Some of these cases could be avoided by refactoring but this is left
      for future work.
      
      We also bump the haddock submodule as it uses UniqFM.
      c4de6a7a
  11. 01 Jul, 2020 1 commit
    • 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
  12. 26 Jun, 2020 1 commit
    • 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
  13. 17 Jun, 2020 1 commit
    • Krzysztof Gogolewski's avatar
      Linear types (#15981) · 40fa237e
      Krzysztof Gogolewski authored
      This is the first step towards implementation of the linear types proposal
      (https://github.com/ghc-proposals/ghc-proposals/pull/111).
      
      It features
      
      * A language extension -XLinearTypes
      * Syntax for linear functions in the surface language
      * Linearity checking in Core Lint, enabled with -dlinear-core-lint
      * Core-to-core passes are mostly compatible with linearity
      * Fields in a data type can be linear or unrestricted; linear fields
        have multiplicity-polymorphic constructors.
        If -XLinearTypes is disabled, the GADT syntax defaults to linear fields
      
      The following items are not yet supported:
      
      * a # m -> b syntax (only prefix FUN is supported for now)
      * Full multiplicity inference (multiplicities are really only checked)
      * Decent linearity error messages
      * Linear let, where, and case expressions in the surface language
        (each of these currently introduce the unrestricted variant)
      * Multiplicity-parametric fields
      * Syntax for annotating lambda-bound or let-bound with a multiplicity
      * S...
      40fa237e
  14. 13 Jun, 2020 2 commits
    • Sylvain Henry's avatar
      Enhance UnitId use · e7272d53
      Sylvain Henry authored
      * use UnitId instead of String to identify wired-in units
      * use UnitId instead of Unit in the backend (Unit are only use by
        Backpack to produce type-checked interfaces, not real code)
      * rename lookup functions for consistency
      * documentation
      e7272d53
    • Sylvain Henry's avatar
      Refactor homeUnit · 72d08610
      Sylvain Henry authored
      * rename thisPackage into homeUnit
      * document and refactor several Backpack things
      72d08610
  15. 10 Jun, 2020 1 commit
  16. 01 Jun, 2020 4 commits
  17. 24 May, 2020 1 commit
    • Joshua Price's avatar
      Make Unicode brackets opening/closing tokens (#18225) · cd339ef0
      Joshua Price authored
      The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as
      described in GHC Proposal #229. This commit makes the unicode
      variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII
      counterparts.
      cd339ef0
  18. 30 Apr, 2020 2 commits
    • Sylvain Henry's avatar
      Unit: split and rename modules · 8bfb0219
      Sylvain Henry authored
      Introduce GHC.Unit.* hierarchy for everything concerning units, packages
      and modules.
      
      Update Haddock submodule
      8bfb0219
    • Sylvain Henry's avatar
      Refactoring unit management code · 10d15f1e
      Sylvain Henry authored
      Over the years the unit management code has been modified a lot to keep
      up with changes in Cabal (e.g. support for several library components in
      the same package), to integrate BackPack, etc. I found it very hard to
      understand as the terminology wasn't consistent, was referring to past
      concepts, etc.
      
      The terminology is now explained as clearly as I could in the Note
      "About Units" and the code is refactored to reflect it.
      
      -------------------
      
      Many names were misleading: UnitId is not an Id but could be a virtual
      unit (an indefinite one instantiated on the fly), IndefUnitId
      constructor may contain a definite instantiated unit, etc.
      
         * Rename IndefUnitId into InstantiatedUnit
         * Rename IndefModule into InstantiatedModule
         * Rename UnitId type into Unit
         * Rename IndefiniteUnitId constructor into VirtUnit
         * Rename DefiniteUnitId constructor into RealUnit
         * Rename packageConfigId into mkUnit
         * Rename getPackageDetails into unsafeGetUnitInfo
         * Rename InstalledUnitId into UnitId
      
      Remove references to misleading ComponentId: a ComponentId is just an
      indefinite unit-id to be instantiated.
      
         * Rename ComponentId into IndefUnitId
         * Rename ComponentDetails into UnitPprInfo
         * Fix display of UnitPprInfo with empty version: this is now used for
           units dynamically generated by BackPack
      
      Generalize several types (Module, Unit, etc.) so that they can be used
      with different unit identifier types: UnitKey, UnitId, Unit, etc.
      
         * GenModule: Module, InstantiatedModule and InstalledModule are now
           instances of this type
         * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
           PackageDatabase
      
      Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.
      
      Add basic support for UnitKey. They should be used more in the future to
      avoid mixing them up with UnitId as we do now.
      
      Add many comments.
      
      Update Haddock submodule
      10d15f1e
  19. 26 Apr, 2020 1 commit
  20. 18 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      Modules (#13009) · 15312bbb
      Sylvain Henry authored
      * SysTools
      * Parser
      * GHC.Builtin
      * GHC.Iface.Recomp
      * Settings
      
      Update Haddock submodule
      
      Metric Decrease:
          Naperian
          parsing001
      15312bbb
  21. 07 Apr, 2020 1 commit
  22. 29 Mar, 2020 1 commit
  23. 29 Feb, 2020 1 commit
    • Vladislav Zavialov's avatar
      Monotonic locations (#17632) · 327b29e1
      Vladislav Zavialov authored
      When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the
      tool may insert #line pragmas to adjust the locations reported to the user.
      
      As the result, the locations recorded in RealSrcLoc are not monotonic. Elements
      that appear later in the StringBuffer are not guaranteed to have a higher
      line/column number.
      
      In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily
      modify locations. This lack of guarantees makes ideas such as #17544
      infeasible.
      
      This patch adds an additional bit of information to every SrcLoc:
      
      	newtype BufPos = BufPos { bufPos :: Int }
      
      A BufPos represents the location in the StringBuffer, unaffected by any
      pragmas.
      
      Updates haddock submodule.
      
      Metric Increase:
          haddock.Cabal
          haddock.base
          haddock.compiler
          MultiLayerModules
          Naperian
          parsing001
          T12150
      327b29e1
  24. 22 Feb, 2020 2 commits
    • Sylvain Henry's avatar
      Modules: Driver (#13009) · 240f5bf6
      Sylvain Henry authored
      submodule updates: nofib, haddock
      240f5bf6
    • Vladislav Zavialov's avatar
      Parser API annotations: RealSrcLoc · be7068a6
      Vladislav Zavialov authored
      During parsing, GHC collects lexical information about AST nodes and
      stores it in a map. It is needed to faithfully restore original source
      code, e.g. compare these expressions:
      
      	a =  b
      	a  = b
      
      The position of the equality sign is not recorded in the AST, so it must
      be stored elsewhere.
      
      This system is described in Note [Api annotations].
      
      Before this patch, the mapping was represented by:
      
      	Map (SrcSpan, AnnKeywordId) SrcSpan
      
      After this patch, the mapping is represented by:
      
      	Map (RealSrcSpan, AnnKeywordId) RealSrcSpan
      
      The motivation behind this change is to avoid using the Ord SrcSpan
      instance (required by Map here), as it interferes with #17632 (see the
      discussion there).
      
      SrcSpan is isomorphic to  Either String RealSrcSpan,  but we shouldn't
      use those strings as Map keys. Those strings are intended as hints to
      the user, e.g. "<interactive>" or "<compiler-generated code>", so they
      are not a valid way to identify nodes in the source code.
      be7068a6
  25. 19 Feb, 2020 1 commit
    • Vladislav Zavialov's avatar
      Remove the MonadFail P instance · 40d917fb
      Vladislav Zavialov authored
      There were two issues with this instance:
      
      * its existence meant that a pattern match failure in the P monad would
        produce a user-visible parse error, but the error message would not be
        helpful to the user
      
      * due to the MFP migration strategy, we had to use CPP in Lexer.x,
        and that created issues for #17750
      
      Updates haddock submodule.
      40d917fb
  26. 11 Feb, 2020 1 commit
  27. 27 Jan, 2020 1 commit
  28. 04 Jan, 2020 1 commit
  29. 02 Dec, 2019 1 commit
  30. 27 Nov, 2019 1 commit
    • Vladislav Zavialov's avatar
      Whitespace-sensitive bang patterns (#1087, #17162) · 8168b42a
      Vladislav Zavialov authored
      This patch implements a part of GHC Proposal #229 that covers five
      operators:
      
      * the bang operator (!)
      * the tilde operator (~)
      * the at operator (@)
      * the dollar operator ($)
      * the double dollar operator ($$)
      
      Based on surrounding whitespace, these operators are disambiguated into
      bang patterns, lazy patterns, strictness annotations, type
      applications, splices, and typed splices.
      
      This patch doesn't cover the (-) operator or the -Woperator-whitespace
      warning, which are left as future work.
      8168b42a
  31. 15 Jul, 2019 2 commits