diff options
-rw-r--r-- | compiler/parser/Parser.y | 3 | ||||
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10255.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10278.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10312.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10399.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T11018.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/exampleTest.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/parseTree.stdout | 2 |
9 files changed, 19 insertions, 7 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 0e93dd043b..6b0317bd9c 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1882,7 +1882,8 @@ is connected to the first type too. type :: { LHsType GhcPs } : btype { $1 } - | btype '->' ctype {% ams (sLL $1 $> $ HsFunTy noExt $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExt $1 $3) [mu AnnRarrow $2] } diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index 22de5ac63f..44159dc35d 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -649,7 +649,7 @@ mkGadtDecl names ty , con_args = args' , con_res_ty = res_ty , con_doc = Nothing } - , anns1 ++ anns2 ++ anns3) + , anns1 ++ anns2) where (ty'@(L l _),anns1) = peel_parens ty [] (tvs, rho) = splitLHsForAllTy ty' @@ -660,14 +660,13 @@ mkGadtDecl names ty split_rho (L l (HsParTy _ ty)) ann = split_rho ty (ann++mkParensApiAnn l) split_rho tau ann = (Nothing, tau, ann) - (args, res_ty, anns3) = split_tau tau [] + (args, res_ty) = split_tau tau args' = nudgeHsSrcBangs args -- See Note [GADT abstract syntax] in HsDecls - split_tau (L _ (HsFunTy _ (L loc (HsRecTy _ rf)) res_ty)) ann - = (RecCon (L loc rf), res_ty, ann) - split_tau (L l (HsParTy _ ty)) ann = split_tau ty (ann++mkParensApiAnn l) - split_tau tau ann = (PrefixCon [], tau, ann) + split_tau (L _ (HsFunTy _ (L loc (HsRecTy _ rf)) res_ty)) + = (RecCon (L loc rf), res_ty) + split_tau tau = (PrefixCon [], tau) peel_parens (L l (HsParTy _ ty)) ann = peel_parens ty (ann++mkParensApiAnn l) diff --git a/testsuite/tests/ghc-api/annotations/T10255.stdout b/testsuite/tests/ghc-api/annotations/T10255.stdout index 994c76fc81..494136d48c 100644 --- a/testsuite/tests/ghc-api/annotations/T10255.stdout +++ b/testsuite/tests/ghc-api/annotations/T10255.stdout @@ -16,6 +16,7 @@ ((Test10255.hs:6:6-26,AnnDcolon), [Test10255.hs:6:8-9]), ((Test10255.hs:6:11-26,AnnCloseP), [Test10255.hs:6:26]), ((Test10255.hs:6:11-26,AnnOpenP), [Test10255.hs:6:11]), +((Test10255.hs:6:12-18,AnnRarrow), [Test10255.hs:6:20-21]), ((Test10255.hs:6:12-25,AnnRarrow), [Test10255.hs:6:20-21]), ((<no location info>,AnnEofPos), [Test10255.hs:8:1]) ] diff --git a/testsuite/tests/ghc-api/annotations/T10278.stdout b/testsuite/tests/ghc-api/annotations/T10278.stdout index dcaf80d0c5..afac1f6f3d 100644 --- a/testsuite/tests/ghc-api/annotations/T10278.stdout +++ b/testsuite/tests/ghc-api/annotations/T10278.stdout @@ -33,6 +33,7 @@ ((Test10278.hs:(8,20)-(10,57),AnnForall), [Test10278.hs:8:20-25]), ((Test10278.hs:(8,32)-(10,57),AnnDot), [Test10278.hs:8:43]), ((Test10278.hs:(8,32)-(10,57),AnnForall), [Test10278.hs:8:32-37]), +((Test10278.hs:9:27-50,AnnRarrow), [Test10278.hs:10:31-32]), ((Test10278.hs:(9,27)-(10,57),AnnRarrow), [Test10278.hs:10:31-32]), ((Test10278.hs:9:38-50,AnnCloseP), [Test10278.hs:9:50]), ((Test10278.hs:9:38-50,AnnOpenP), [Test10278.hs:9:38]), diff --git a/testsuite/tests/ghc-api/annotations/T10312.stdout b/testsuite/tests/ghc-api/annotations/T10312.stdout index c7b25a7996..939a78e478 100644 --- a/testsuite/tests/ghc-api/annotations/T10312.stdout +++ b/testsuite/tests/ghc-api/annotations/T10312.stdout @@ -171,6 +171,7 @@ ((Test10312.hs:68:28-35,AnnOpenP), [Test10312.hs:68:28]), ((Test10312.hs:68:28-35,AnnRarrow), [Test10312.hs:68:37-38]), ((Test10312.hs:68:28-51,AnnRarrow), [Test10312.hs:68:37-38]), +((Test10312.hs:68:29,AnnRarrow), [Test10312.hs:68:31-32]), ((Test10312.hs:68:29-34,AnnRarrow), [Test10312.hs:68:31-32]), ((Test10312.hs:68:40-42,AnnCloseS), [Test10312.hs:68:42]), ((Test10312.hs:68:40-42,AnnOpenS), [Test10312.hs:68:40]), diff --git a/testsuite/tests/ghc-api/annotations/T10399.stdout b/testsuite/tests/ghc-api/annotations/T10399.stdout index c50b5b9135..24f1cf41a3 100644 --- a/testsuite/tests/ghc-api/annotations/T10399.stdout +++ b/testsuite/tests/ghc-api/annotations/T10399.stdout @@ -55,8 +55,11 @@ ((Test10399.hs:16:28-43,AnnDarrow), [Test10399.hs:16:45-46]), ((Test10399.hs:16:28-43,AnnOpenP), [Test10399.hs:16:28, Test10399.hs:16:28]), ((Test10399.hs:16:30-33,AnnComma), [Test10399.hs:16:34]), +((Test10399.hs:16:48,AnnRarrow), [Test10399.hs:16:50-51]), ((Test10399.hs:(16,48)-(17,68),AnnRarrow), [Test10399.hs:16:50-51]), +((Test10399.hs:16:53-66,AnnRarrow), [Test10399.hs:17:45-46]), ((Test10399.hs:(16,53)-(17,68),AnnRarrow), [Test10399.hs:17:45-46]), +((Test10399.hs:17:48,AnnRarrow), [Test10399.hs:17:50-51]), ((Test10399.hs:17:48-68,AnnRarrow), [Test10399.hs:17:50-51]), ((Test10399.hs:17:66-68,AnnCloseS), [Test10399.hs:17:68]), ((Test10399.hs:17:66-68,AnnOpenS), [Test10399.hs:17:66]), @@ -69,6 +72,7 @@ ((Test10399.hs:18:20-54,AnnForall), [Test10399.hs:18:20-25]), ((Test10399.hs:18:31-36,AnnCloseP), [Test10399.hs:18:36]), ((Test10399.hs:18:31-36,AnnOpenP), [Test10399.hs:18:31]), +((Test10399.hs:18:31-36,AnnRarrow), [Test10399.hs:18:38-39]), ((Test10399.hs:18:31-54,AnnRarrow), [Test10399.hs:18:38-39]), ((Test10399.hs:20:1-25,AnnCloseQ), [Test10399.hs:20:24-25]), ((Test10399.hs:20:1-25,AnnOpen), [Test10399.hs:20:1-3]), diff --git a/testsuite/tests/ghc-api/annotations/T11018.stdout b/testsuite/tests/ghc-api/annotations/T11018.stdout index 78b76400db..6c70c5c3d0 100644 --- a/testsuite/tests/ghc-api/annotations/T11018.stdout +++ b/testsuite/tests/ghc-api/annotations/T11018.stdout @@ -24,6 +24,7 @@ ((Test11018.hs:12:21-32,AnnCloseP), [Test11018.hs:12:32]), ((Test11018.hs:12:21-32,AnnDcolonU), [Test11018.hs:12:24]), ((Test11018.hs:12:21-32,AnnOpenP), [Test11018.hs:12:21]), +((Test11018.hs:12:26,AnnRarrow), [Test11018.hs:12:28-29]), ((Test11018.hs:12:26-31,AnnRarrow), [Test11018.hs:12:28-29]), ((Test11018.hs:(13,16)-(15,7),AnnCloseC), [Test11018.hs:15:7]), ((Test11018.hs:(13,16)-(15,7),AnnOpenC), [Test11018.hs:13:16]), @@ -121,6 +122,7 @@ ((Test11018.hs:37:22-32,AnnCloseP), [Test11018.hs:37:32]), ((Test11018.hs:37:22-32,AnnDcolonU), [Test11018.hs:37:25]), ((Test11018.hs:37:22-32,AnnOpenP), [Test11018.hs:37:22]), +((Test11018.hs:37:27,AnnRarrowU), [Test11018.hs:37:29]), ((Test11018.hs:37:27-31,AnnRarrowU), [Test11018.hs:37:29]), ((Test11018.hs:(38,17)-(40,7),AnnCloseC), [Test11018.hs:40:7]), ((Test11018.hs:(38,17)-(40,7),AnnOpenC), [Test11018.hs:38:17]), diff --git a/testsuite/tests/ghc-api/annotations/exampleTest.stdout b/testsuite/tests/ghc-api/annotations/exampleTest.stdout index 3c7a5af418..2cdef957d3 100644 --- a/testsuite/tests/ghc-api/annotations/exampleTest.stdout +++ b/testsuite/tests/ghc-api/annotations/exampleTest.stdout @@ -64,6 +64,7 @@ ((AnnotationTuple.hs:18:1-28,AnnDcolon), [AnnotationTuple.hs:18:20-21]), ((AnnotationTuple.hs:18:1-28,AnnFamily), [AnnotationTuple.hs:18:6-11]), ((AnnotationTuple.hs:18:1-28,AnnSemi), [AnnotationTuple.hs:19:1]), +((AnnotationTuple.hs:18:23,AnnRarrow), [AnnotationTuple.hs:18:25-26]), ((AnnotationTuple.hs:18:23-28,AnnRarrow), [AnnotationTuple.hs:18:25-26]), ((AnnotationTuple.hs:(20,1)-(24,14),AnnFunId), [AnnotationTuple.hs:20:1-5]), ((AnnotationTuple.hs:(20,1)-(24,14),AnnSemi), [AnnotationTuple.hs:25:1]), diff --git a/testsuite/tests/ghc-api/annotations/parseTree.stdout b/testsuite/tests/ghc-api/annotations/parseTree.stdout index e229ba626a..092ba971d2 100644 --- a/testsuite/tests/ghc-api/annotations/parseTree.stdout +++ b/testsuite/tests/ghc-api/annotations/parseTree.stdout @@ -130,6 +130,8 @@ (AK AnnotationTuple.hs:18:1-28 AnnSemi = [AnnotationTuple.hs:19:1]) +(AK AnnotationTuple.hs:18:23 AnnRarrow = [AnnotationTuple.hs:18:25-26]) + (AK AnnotationTuple.hs:18:23-28 AnnRarrow = [AnnotationTuple.hs:18:25-26]) (AK AnnotationTuple.hs:(20,1)-(24,14) AnnFunId = [AnnotationTuple.hs:20:1-5]) |