summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer
Commit message (Collapse)AuthorAgeFilesLines
* EPA: Add SourceText to HsOverLabelAlan Zimmerman2023-01-233-1/+54
| | | | | | To be able to capture string literals with possible escape codes as labels. Close #22771
* Fix printing of promoted MkSolo datacon (#22785)Andrei Borzenkov2023-01-183-1/+17
| | | | | | | | | | | | Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo, and Solo was turned into a pattern synonym for backwards compatibility. Since pattern synonyms can not be promoted, the old code that pretty-printed promoted single-element tuples started producing ill-typed code: t :: Proxy ('Solo Int) This fails with "Pattern synonym ‘Solo’ used as a type" The solution is to track the distinction between type constructors and data constructors more carefully when printing single-element tuples.
* EPA: Add annotation for 'type' in DataDeclAlan Zimmerman2023-01-163-1/+69
| | | | Closes #22765
* EPA: exact print HsDocTyAlan Zimmerman2023-01-093-1/+14
| | | | | To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121
* EPA: Do not collect comments from end of fileAlan Zimmerman2023-01-051-9/+9
| | | | | | | | 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.
* EPA: Make EOF position part of AnnsModuleAlan Zimmerman2022-12-222-24/+18
| | | | | Closes #20951 Closes #19697
* EPA: When splitting out header comments, keep ones for first declAlan Zimmerman2022-12-131-0/+1
| | | | | Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead.
* Print unticked promoted data constructors (#20531)Vladislav Zavialov2022-11-259-19/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi@wzrd.ht>
* Check if the SDoc starts with a single quote (#22488)Vladislav Zavialov2022-11-234-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote.
* Update the check-exact infrastructure to match ghc-exactprintAlan Zimmerman2022-10-173-0/+17
| | | | | | | | | | | | | | | | | | | | GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355
* implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)Ross Paterson2022-09-271-0/+1
| | | | includes corresponding changes to haddock submodule
* Scrub partiality about `NewOrData`.M Farkas-Dyck2022-09-191-67/+69
| | | | | | | | Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule.
* Diagnostic codes: acccept test changessheaf2022-09-135-10/+10
| | | | | | | | The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes.
* EPA: DotFieldOcc does not have exact print annotationsAlan Zimmerman2022-08-113-0/+9
| | | | | | | | | | | | | | | | | For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule
* Remove many GHC dependencies from L.H.Sromes2022-07-061-13/+6
| | | | | | | | | | | | | | | | | | Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits -------------------------
* TTG: Move ImpExp client-independent bits to L.H.S.ImpExpromes2022-07-032-94/+97
| | | | | | | | | | | Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule
* testsuite: Use normalise_version more consistentlyBen Gamari2022-06-271-1/+1
| | | | | Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this.
* Bump ghc-prim and base versionsBen Gamari2022-06-271-1/+1
| | | | | | | | | To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)
* Deprecate TypeInType extensionHaskellMouse2022-06-062-2/+2
| | | | | | | | | | | | | | | | This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875
* TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hswip/romes/ttg-matchgroup-originromes2022-05-261-18/+14
|
* Fix printing of brackets in multiplicities (#20315)jackohughes2022-05-133-0/+11
| | | | | | | | | Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315
* EPA: do statement with leading semicolon has wrong anchorAlan Zimmerman2022-05-113-0/+11
| | | | | | | | | | | | | The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256
* HsUniToken for :: in GADT constructors (#19623)Vladislav Zavialov2022-04-081-1/+5
| | | | | | One more step towards the new design of EPA. Updates the haddock submodule.
* Implement \cases (Proposal 302)Jakob Bruenker2022-04-012-0/+16
| | | | | | | | | | | | This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768
* Change GHC.Prim to GHC.Exts in docs and testsKrzysztof Gogolewski2022-04-012-2/+2
| | | | | Users are supposed to import GHC.Exts rather than GHC.Prim. Part of #18749.
* EPA: let stmt with semicolon has wrong anchorAlan Zimmerman2022-03-283-0/+11
| | | | | | | | | | | | | The code let ;x =1 Captures the semicolon annotation, but did not widen the anchor in the ValBinds. Fix that. Closes #20247
* Fix panic trying to -ddump-parsed-ast for implicit fixityAlan Zimmerman2021-12-223-0/+9
| | | | | | | | | | | | | | A declaration such as infixr ++++ is supplied with an implicit fixity of 9 in the parser, but uses an invalid SrcSpan to capture this. Use of this span triggers a panic. Fix the problem by not recording an exact print annotation for the non-existent fixity source. Closes #20846
* EPA: Get rid of bare SrcSpan's in the ParsedSourceAlan Zimmerman2021-11-021-6/+18
| | | | | | | | | | | | | The ghc-exactPrint library has had to re-introduce the relatavise phase. This is needed if you change the length of an identifier and want the layout to be preserved afterwards. It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn NoEpAnns` for them instead. Updates haddock submodule.
* EPA: Use LocatedA for ModuleNameAlan Zimmerman2021-10-242-3/+3
| | | | | This allows us to use an Anchor with a DeltaPos in it when exact printing.
* hadrian: avoid building check-{exact,ppr} and count-deps when the tests ↵Zubin Duggal2021-10-131-145/+147
| | | | | | don't need them hadrian: build optional dependencies with test compiler
* Bespoke TokenLocation data typeVladislav Zavialov2021-10-041-7/+2
| | | | | | | | | | | | The EpaAnnCO we were using contained an Anchor instead of EpaLocation, making it harder to work with. At the same time, using EpaLocation by itself isn't possible either, as we may have tokens without location information. Hence the new data type: data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation
* Add `-dsuppress-core-sizes` flag (#20342)Sylvain Henry2021-09-281-0/+3
| | | | | This flag is used to remove the output of core stats per binding in Core dumps.
* EPA: correctly capture comments between 'where' and bindsAlan Zimmerman2021-09-174-1/+686
| | | | | | | | | | | | In the following foo = x where -- do stuff doStuff = do stuff The "-- do stuff" comment is captured in the HsValBinds. Closes #20297
* Only dump Core stats when requested to do so (#20342)Sylvain Henry2021-09-081-3/+3
|
* EPA: Capture '+' location for NPlusKPatAlan Zimmerman2021-09-083-0/+49
| | | | | | | The location of the plus symbol was being discarded, we now capture it. Closes #20243
* EPA: order of semicolons and comments for top-level decls is wrongAlan Zimmerman2021-09-063-0/+86
| | | | | | | | | | A comment followed by a semicolon at the top level resulted in the preceding comments being attached to the following declaration. Capture the comments as belonging to the declaration preceding the semicolon instead. Closes #20258
* Supply missing case for '.' inShayne Fletcher2021-08-021-3/+1
|
* Add a regression test for #17697Krzysztof Gogolewski2021-07-273-0/+15
|
* EPA: Bringing over tests and updates from ghc-exactprintAlan Zimmerman2021-06-2426-0/+981
|
* Typos, minor comment fixesKrzysztof Gogolewski2021-06-221-6/+0
| | | | | | | | | | | | | | | | | | | - Remove fstName, sndName, fstIdKey, sndIdKey - no longer used, removed from basicKnownKeyNames - Remove breakpointId, breakpointCondId, opaqueTyCon, unknownTyCon - they were used in the old implementation of the GHCi debugger - Fix typos in comments - Remove outdated comment in Lint.hs - Use 'LitRubbish' instead of 'RubbishLit' for consistency - Remove comment about subkinding - superseded by Note [Kind Constraint and kind Type] - Mention ticket ID in a linear types error message - Fix formatting in using-warnings.rst and linear-types.rst - Remove comment about 'Any' in Dynamic.hs - Dynamic now uses Typeable + existential instead of Any - Remove codeGen/should_compile/T13233.hs This was added by accident, it is not used and T13233 is already in should_fail
* HsUniToken and HsToken for HsArrow (#19623)Vladislav Zavialov2021-06-161-3/+12
| | | | | | Another step towards a simpler design for exact printing. Updates the haddock submodule.
* [EPA] exact print linear arrows.Alan Zimmerman2021-05-273-0/+38
| | | | | | | | Closes #19903 Note: the normal ppr does not reproduce unicode linear arrows, so that part of the normal printing test is ommented out in the Makefile for this test. See #18846
* check-{ppr/exact}: Rewrite more directly to just parse filesMatthew Pickering2021-05-246-219/+0
| | | | | | There was quite a large amount of indirection in these tests, so I have rewritten them to just directly parse the files rather than making a module graph and entering other twisty packages.
* EPA: AnnAt missing for type application in patternsAlan Zimmerman2021-05-233-0/+20
| | | | | | | | | | Ensure that the exact print annotations accurately record the `@` for code like tyApp :: Con k a -> Proxy a tyApp (Con @kx @ax (x :: Proxy ax)) = x :: Proxy (ax :: kx) Closes #19850
* EPA: Fix explicit specificity and unicode linear arrow annotationsAlan Zimmerman2021-05-214-0/+31
| | | | | Closes #19839 Closes #19840
* EPA: Remove duplicate annotations from HsDataDefnAlan Zimmerman2021-05-194-10/+10
| | | | | | | | They are repeated in the surrounding DataDecl and FamEqn. Updates haddock submodule Closes #19834
* Remove transitive information about modules and packages from interface filesMatthew Pickering2021-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit modifies interface files so that *only* direct information about modules and packages is stored in the interface file. * Only direct module and direct package dependencies are stored in the interface files. * Trusted packages are now stored separately as they need to be checked transitively. * hs-boot files below the compiled module in the home module are stored so that eps_is_boot can be calculated in one-shot mode without loading all interface files in the home package. * The transitive closure of signatures is stored separately This is important for two reasons * Less recompilation is needed, as motivated by #16885, a lot of redundant compilation was triggered when adding new imports deep in the module tree as all the parent interface files had to be redundantly updated. * Checking an interface file is cheaper because you don't have to perform a transitive traversal to check the dependencies are up-to-date. In the code, places where we would have used the transitive closure, we instead compute the necessary transitive closure. The closure is not computed very often, was already happening in checkDependencies, and was already happening in getLinkDeps. Fixes #16885 ------------------------- Metric Decrease: MultiLayerModules T13701 T13719 -------------------------
* EPA: Fix incorrect SrcSpan for FamDeclAlan Zimmerman2021-05-123-0/+16
| | | | | | | The SrcSpan for a type family declaration did not include the family equations. Closes #19821
* EPA: record annotations for braces in LetStmtAlan Zimmerman2021-05-113-0/+11
| | | | Closes #19814
* EPA: Use custom AnnsIf structure for HsIf and HsCmdIfAlan Zimmerman2021-05-113-0/+29
| | | | | | | This clearly identifies the presence and location of optional semicolons in an if statement. Closes #19813