[Git][ghc/ghc][master] EPA: Keep comments in a CaseAlt match
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Apr 23 14:20:41 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
e916fc92 by Alan Zimmerman at 2024-04-23T10:19:50-04:00
EPA: Keep comments in a CaseAlt match
The comments now live in the surrounding location, not inside the
Match. Make sure we keep them.
Closes #24707
- - - - -
4 changed files:
- compiler/GHC/Parser.y
- + testsuite/tests/printer/CaseAltComments.hs
- testsuite/tests/printer/Makefile
- testsuite/tests/printer/all.T
Changes:
=====================================
compiler/GHC/Parser.y
=====================================
@@ -3342,7 +3342,7 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs
alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) }
: PATS alt_rhs { $2 >>= \ $2 ->
- acsA (sLLAsl $1 $> ()) (\loc cs -> L (locA loc)
+ amsA' (sLLAsl $1 $>
(Match { m_ext = []
, m_ctxt = CaseAlt -- for \case and \cases, this will be changed during post-processing
, m_pats = $1
=====================================
testsuite/tests/printer/CaseAltComments.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE PatternGuards #-}
+module CaseAltComments where
+
+nfCom = case expr of
+ x :*: y -- comment
+ | x' <= y' -> x' :*: y'
+ _ -> blah
=====================================
testsuite/tests/printer/Makefile
=====================================
@@ -826,3 +826,8 @@ Test24533:
PprLetIn:
$(CHECK_PPR) $(LIBDIR) PprLetIn.hs
$(CHECK_EXACT) $(LIBDIR) PprLetIn.hs
+
+.PHONY: CaseAltComments
+CaseAltComments:
+ $(CHECK_PPR) $(LIBDIR) CaseAltComments.hs
+ $(CHECK_EXACT) $(LIBDIR) CaseAltComments.hs
=====================================
testsuite/tests/printer/all.T
=====================================
@@ -198,3 +198,4 @@ test('ListTuplePuns', extra_files(['ListTuplePuns.hs']), ghci_script, ['ListTupl
test('AnnotationNoListTuplePuns', [ignore_stderr, req_ppr_deps], makefile_test, ['AnnotationNoListTuplePuns'])
test('Test24533', [ignore_stderr, req_ppr_deps], makefile_test, ['Test24533'])
test('PprLetIn', [ignore_stderr, req_ppr_deps], makefile_test, ['PprLetIn'])
+test('CaseAltComments', [ignore_stderr, req_ppr_deps], makefile_test, ['CaseAltComments'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e916fc9215e66b15c7e2387cc087a9d1cc57bf77
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e916fc9215e66b15c7e2387cc087a9d1cc57bf77
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/20240423/d1500912/attachment-0001.html>
More information about the ghc-commits
mailing list