[Git][ghc/ghc][wip/int-index/ppr-tick] 2 commits: Check if the SDoc starts with a single quote (#22488)

Vladislav Zavialov (@int-index) gitlab at gitlab.haskell.org
Wed Nov 23 06:10:36 UTC 2022



Vladislav Zavialov pushed to branch wip/int-index/ppr-tick at Glasgow Haskell Compiler / GHC


Commits:
8a90b2ce by Vladislav Zavialov at 2022-11-22T16:42:18+03:00
Check if the SDoc starts with a single quote (#22488)

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.

- - - - -
afa9c2f2 by Vladislav Zavialov at 2022-11-23T09:09:23+03:00
Draft: Print unticked promoted data constructors (WIP: 20531)

Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht>

- - - - -


30 changed files:

- compiler/GHC.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/Runtime/Context.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Name/Ppr.hs
- compiler/GHC/Utils/Misc.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Ppr.hs
- docs/users_guide/using.rst
- testsuite/tests/dependent/should_fail/T11471.stderr
- testsuite/tests/dependent/should_fail/T13135_simple.stderr
- testsuite/tests/dependent/should_fail/T17131.stderr
- testsuite/tests/dependent/should_fail/T17541.stderr
- testsuite/tests/ffi/should_fail/T21305_fail.stderr
- testsuite/tests/gadt/T7293.stderr
- testsuite/tests/gadt/T7294.stderr
- testsuite/tests/ghci/T18060/T18060.stdout
- testsuite/tests/ghci/T18262/T18262.stdout
- testsuite/tests/ghci/scripts/GhciKinds.stdout


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23cd7b4cacdfe132f5b64c5ca5f8fc142d5589cc...afa9c2f264dac978012f1a6063abe13e5a0237f9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23cd7b4cacdfe132f5b64c5ca5f8fc142d5589cc...afa9c2f264dac978012f1a6063abe13e5a0237f9
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221123/a92d95ef/attachment.html>


More information about the ghc-commits mailing list