From d5bea4d6bce785b1d09f1b8faad7451af23b728d Mon Sep 17 00:00:00 2001 From: Alan Zimmerman <alan.zimm@gmail.com> Date: Tue, 23 Apr 2024 20:39:17 +0100 Subject: [PATCH] EPA: Fix range for GADT decl with sig only Closes #24714 --- compiler/GHC/Parser.y | 2 +- testsuite/tests/printer/DataDeclShort.hs | 8 ++++++++ testsuite/tests/printer/Makefile | 5 +++++ testsuite/tests/printer/all.T | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/printer/DataDeclShort.hs diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 492e04456f4..e4b6661b022 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -1303,7 +1303,7 @@ ty_decl :: { LTyClDecl GhcPs } | type_data_or_newtype capi_ctype tycl_hdr opt_kind_sig gadt_constrlist maybe_derivings - {% mkTyData (comb4 $1 $3 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 + {% mkTyData (comb5 $1 $3 $4 $5 $6) (sndOf3 $ unLoc $1) (thdOf3 $ unLoc $1) $2 $3 (snd $ unLoc $4) (snd $ unLoc $5) (fmap reverse $6) ((fstOf3 $ unLoc $1)++(fst $ unLoc $4)++(fst $ unLoc $5)) } diff --git a/testsuite/tests/printer/DataDeclShort.hs b/testsuite/tests/printer/DataDeclShort.hs new file mode 100644 index 00000000000..dc85819b7f8 --- /dev/null +++ b/testsuite/tests/printer/DataDeclShort.hs @@ -0,0 +1,8 @@ +module DataDeclShort where + +data GenericOptions + :: fieldLabelModifier + -> tagSingleConstructors + -> Type + +x = 1 diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile index df94e3d3fce..a3eec175473 100644 --- a/testsuite/tests/printer/Makefile +++ b/testsuite/tests/printer/Makefile @@ -836,3 +836,8 @@ CaseAltComments: MatchPatComments: $(CHECK_PPR) $(LIBDIR) MatchPatComments.hs $(CHECK_EXACT) $(LIBDIR) MatchPatComments.hs + +.PHONY: DataDeclShort +DataDeclShort: + $(CHECK_PPR) $(LIBDIR) DataDeclShort.hs + $(CHECK_EXACT) $(LIBDIR) DataDeclShort.hs diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T index 6c7bde8460e..bd546b0ae10 100644 --- a/testsuite/tests/printer/all.T +++ b/testsuite/tests/printer/all.T @@ -200,3 +200,4 @@ 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']) test('MatchPatComments', [ignore_stderr, req_ppr_deps], makefile_test, ['MatchPatComments']) +test('DataDeclShort', [ignore_stderr, req_ppr_deps], makefile_test, ['DataDeclShort']) -- GitLab