diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2019-01-22 23:29:25 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-01-27 08:32:12 -0500 |
commit | 3cf12e6081e7a9f0c3d515de52ffd079186816a5 (patch) | |
tree | adbdf5e5fe78a2da3954259a1cce19d7911cb001 | |
parent | 5cb071af5b02b7433b2bb4d06062ac8b6fb387e8 (diff) | |
download | haskell-3cf12e6081e7a9f0c3d515de52ffd079186816a5.tar.gz |
check-api-annotations checks for annotation preceding its span
For an API annotation to be useful, it must not occur before the span
it is enclosed in.
So, for check-api-annotation output, a line such as
((Test16212.hs:3:22-36,AnnOpenP), [Test16212.hs:3:21]),
should be flagged as an error, as the AnnOpenP location of 3:21
precedes its enclosing span of 3:22-26.
This patch does this.
Closes #16217
30 files changed, 237 insertions, 31 deletions
diff --git a/testsuite/tests/ghc-api/annotations/Makefile b/testsuite/tests/ghc-api/annotations/Makefile index 98b45744ce..2478f29ff0 100644 --- a/testsuite/tests/ghc-api/annotations/Makefile +++ b/testsuite/tests/ghc-api/annotations/Makefile @@ -145,3 +145,7 @@ T13163: .PHONY: T15303 T15303: $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test15303.hs + +.PHONY: T16212 +T16212: + $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test16212.hs diff --git a/testsuite/tests/ghc-api/annotations/T10255.stdout b/testsuite/tests/ghc-api/annotations/T10255.stdout index 494136d48c..60e632a3e8 100644 --- a/testsuite/tests/ghc-api/annotations/T10255.stdout +++ b/testsuite/tests/ghc-api/annotations/T10255.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10268.stdout b/testsuite/tests/ghc-api/annotations/T10268.stdout index 399393d653..3739b7b0b7 100644 --- a/testsuite/tests/ghc-api/annotations/T10268.stdout +++ b/testsuite/tests/ghc-api/annotations/T10268.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10269.stdout b/testsuite/tests/ghc-api/annotations/T10269.stdout index 679ac6d887..f0589a0551 100644 --- a/testsuite/tests/ghc-api/annotations/T10269.stdout +++ b/testsuite/tests/ghc-api/annotations/T10269.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [(AnnVal, Test10269.hs:4:4-6)] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10276.stdout b/testsuite/tests/ghc-api/annotations/T10276.stdout index 43cd72ae7a..2ed6318905 100644 --- a/testsuite/tests/ghc-api/annotations/T10276.stdout +++ b/testsuite/tests/ghc-api/annotations/T10276.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10278.stdout b/testsuite/tests/ghc-api/annotations/T10278.stdout index afac1f6f3d..dd6fa432de 100644 --- a/testsuite/tests/ghc-api/annotations/T10278.stdout +++ b/testsuite/tests/ghc-api/annotations/T10278.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10280.stdout b/testsuite/tests/ghc-api/annotations/T10280.stdout index 559e6f65c0..aa488a4ae3 100644 --- a/testsuite/tests/ghc-api/annotations/T10280.stdout +++ b/testsuite/tests/ghc-api/annotations/T10280.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10307.stdout b/testsuite/tests/ghc-api/annotations/T10307.stdout index 48cbca6cd0..47c995d84b 100644 --- a/testsuite/tests/ghc-api/annotations/T10307.stdout +++ b/testsuite/tests/ghc-api/annotations/T10307.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10309.stdout b/testsuite/tests/ghc-api/annotations/T10309.stdout index 6f77d83b7a..332220a3ba 100644 --- a/testsuite/tests/ghc-api/annotations/T10309.stdout +++ b/testsuite/tests/ghc-api/annotations/T10309.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10312.stdout b/testsuite/tests/ghc-api/annotations/T10312.stdout index 939a78e478..3627d0b2c2 100644 --- a/testsuite/tests/ghc-api/annotations/T10312.stdout +++ b/testsuite/tests/ghc-api/annotations/T10312.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10354.stdout b/testsuite/tests/ghc-api/annotations/T10354.stdout index 2e07948323..8f00de0f51 100644 --- a/testsuite/tests/ghc-api/annotations/T10354.stdout +++ b/testsuite/tests/ghc-api/annotations/T10354.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10357.stdout b/testsuite/tests/ghc-api/annotations/T10357.stdout index 15d5139be5..3d4bcd1fc9 100644 --- a/testsuite/tests/ghc-api/annotations/T10357.stdout +++ b/testsuite/tests/ghc-api/annotations/T10357.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10358.stdout b/testsuite/tests/ghc-api/annotations/T10358.stdout index 1854b2d116..604c7dab36 100644 --- a/testsuite/tests/ghc-api/annotations/T10358.stdout +++ b/testsuite/tests/ghc-api/annotations/T10358.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10396.stdout b/testsuite/tests/ghc-api/annotations/T10396.stdout index 0be529fc43..2f7b8848b4 100644 --- a/testsuite/tests/ghc-api/annotations/T10396.stdout +++ b/testsuite/tests/ghc-api/annotations/T10396.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10399.stdout b/testsuite/tests/ghc-api/annotations/T10399.stdout index 24f1cf41a3..75d94b3406 100644 --- a/testsuite/tests/ghc-api/annotations/T10399.stdout +++ b/testsuite/tests/ghc-api/annotations/T10399.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T10598.stdout b/testsuite/tests/ghc-api/annotations/T10598.stdout index af1ac3be58..61d762ce7f 100644 --- a/testsuite/tests/ghc-api/annotations/T10598.stdout +++ b/testsuite/tests/ghc-api/annotations/T10598.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T11018.stdout b/testsuite/tests/ghc-api/annotations/T11018.stdout index 658656f095..b4150305ab 100644 --- a/testsuite/tests/ghc-api/annotations/T11018.stdout +++ b/testsuite/tests/ghc-api/annotations/T11018.stdout @@ -1,5 +1,11 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ +((Test11018.hs:12:22-31,AnnOpenP), [Test11018.hs:12:21]), +((Test11018.hs:37:23-31,AnnOpenP), [Test11018.hs:37:22]) +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T11321.stdout b/testsuite/tests/ghc-api/annotations/T11321.stdout index b88efb42cf..1fe2dbe301 100644 --- a/testsuite/tests/ghc-api/annotations/T11321.stdout +++ b/testsuite/tests/ghc-api/annotations/T11321.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T11332.stdout b/testsuite/tests/ghc-api/annotations/T11332.stdout index cf1d859157..20fcfa98fb 100644 --- a/testsuite/tests/ghc-api/annotations/T11332.stdout +++ b/testsuite/tests/ghc-api/annotations/T11332.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T12417.stdout b/testsuite/tests/ghc-api/annotations/T12417.stdout index 7e642dee66..cc81e6e0b8 100644 --- a/testsuite/tests/ghc-api/annotations/T12417.stdout +++ b/testsuite/tests/ghc-api/annotations/T12417.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T13163.stdout b/testsuite/tests/ghc-api/annotations/T13163.stdout index f216acdf98..99680d1bad 100644 --- a/testsuite/tests/ghc-api/annotations/T13163.stdout +++ b/testsuite/tests/ghc-api/annotations/T13163.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T15303.stdout b/testsuite/tests/ghc-api/annotations/T15303.stdout index 003dab5761..e571918eba 100644 --- a/testsuite/tests/ghc-api/annotations/T15303.stdout +++ b/testsuite/tests/ghc-api/annotations/T15303.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/T16212.stdout b/testsuite/tests/ghc-api/annotations/T16212.stdout new file mode 100644 index 0000000000..5b91c36253 --- /dev/null +++ b/testsuite/tests/ghc-api/annotations/T16212.stdout @@ -0,0 +1,49 @@ +---Problems (should be empty list)--- +[] +---Annotations----------------------- +-- SrcSpan the annotation is attached to, AnnKeywordId, +-- list of locations the keyword item appears in +[ +((Test16212.hs:1:1,AnnModule), [Test16212.hs:1:1-6]), +((Test16212.hs:1:1,AnnWhere), [Test16212.hs:1:18-22]), +((Test16212.hs:(3,1)-(4,37),AnnClass), [Test16212.hs:3:1-5]), +((Test16212.hs:(3,1)-(4,37),AnnSemi), [Test16212.hs:6:1]), +((Test16212.hs:(3,1)-(4,37),AnnWhere), [Test16212.hs:3:39-43]), +((Test16212.hs:3:21-37,AnnCloseP), [Test16212.hs:3:37]), +((Test16212.hs:3:21-37,AnnOpenP), [Test16212.hs:3:21]), +((Test16212.hs:3:22-36,AnnCloseP), [Test16212.hs:3:37]), +((Test16212.hs:3:22-36,AnnDcolon), [Test16212.hs:3:28-29]), +((Test16212.hs:3:22-36,AnnOpenP), [Test16212.hs:3:21]), +((Test16212.hs:4:3-37,AnnDcolon), [Test16212.hs:4:9-10]), +((Test16212.hs:4:29-37,AnnCloseP), [Test16212.hs:4:37]), +((Test16212.hs:4:29-37,AnnOpenP), [Test16212.hs:4:29]), +((Test16212.hs:(6,1)-(7,37),AnnClass), [Test16212.hs:6:1-5]), +((Test16212.hs:(6,1)-(7,37),AnnSemi), [Test16212.hs:9:1]), +((Test16212.hs:(6,1)-(7,37),AnnWhere), [Test16212.hs:6:42-46]), +((Test16212.hs:6:22-40,AnnCloseP), [Test16212.hs:6:40]), +((Test16212.hs:6:22-40,AnnOpenP), [Test16212.hs:6:22]), +((Test16212.hs:6:23-39,AnnCloseP), [Test16212.hs:6:39]), +((Test16212.hs:6:23-39,AnnOpenP), [Test16212.hs:6:23]), +((Test16212.hs:6:24-38,AnnCloseP), [Test16212.hs:6:40, Test16212.hs:6:39]), +((Test16212.hs:6:24-38,AnnDcolon), [Test16212.hs:6:30-31]), +((Test16212.hs:6:24-38,AnnOpenP), [Test16212.hs:6:22, Test16212.hs:6:23]), +((Test16212.hs:7:3-37,AnnDcolon), [Test16212.hs:7:9-10]), +((Test16212.hs:7:29-37,AnnCloseP), [Test16212.hs:7:37]), +((Test16212.hs:7:29-37,AnnOpenP), [Test16212.hs:7:29]), +((Test16212.hs:(9,1)-(11,36),AnnData), [Test16212.hs:9:1-4]), +((Test16212.hs:(9,1)-(11,36),AnnSemi), [Test16212.hs:12:1]), +((Test16212.hs:(9,1)-(11,36),AnnWhere), [Test16212.hs:9:25-29]), +((Test16212.hs:9:10-23,AnnCloseP), [Test16212.hs:9:23]), +((Test16212.hs:9:10-23,AnnOpenP), [Test16212.hs:9:10]), +((Test16212.hs:9:11-22,AnnCloseP), [Test16212.hs:9:23]), +((Test16212.hs:9:11-22,AnnDcolon), [Test16212.hs:9:13-14]), +((Test16212.hs:9:11-22,AnnOpenP), [Test16212.hs:9:10]), +((Test16212.hs:10:5-23,AnnDcolon), [Test16212.hs:10:13-14]), +((Test16212.hs:10:5-23,AnnSemi), [Test16212.hs:11:5]), +((Test16212.hs:11:5-36,AnnDcolon), [Test16212.hs:11:13-14]), +((Test16212.hs:11:16-20,AnnRarrow), [Test16212.hs:11:22-23]), +((Test16212.hs:11:16-36,AnnRarrow), [Test16212.hs:11:22-23]), +((Test16212.hs:11:29-36,AnnCloseP), [Test16212.hs:11:36]), +((Test16212.hs:11:29-36,AnnOpenP), [Test16212.hs:11:29]), +((<no location info>,AnnEofPos), [Test16212.hs:12:1]) +] diff --git a/testsuite/tests/ghc-api/annotations/Test16212.hs b/testsuite/tests/ghc-api/annotations/Test16212.hs new file mode 100644 index 0000000000..6c2baad7e2 --- /dev/null +++ b/testsuite/tests/ghc-api/annotations/Test16212.hs @@ -0,0 +1,11 @@ +module Test16212 where + +class LiftingMonad (trans :: MTrans) where + proof :: Monad m :- Monad (trans m) + +class LiftingMonad2 ((trans :: MTrans)) where + proof :: Monad m :- Monad (trans m) + +data Nat (t :: NatKind) where + ZeroNat :: Nat Zero + SuccNat :: Nat t -> Nat (Succ t) diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T index 666cb3f044..49f0780021 100644 --- a/testsuite/tests/ghc-api/annotations/all.T +++ b/testsuite/tests/ghc-api/annotations/all.T @@ -38,7 +38,8 @@ test('T10399', [extra_files(['Test10399.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory T10399']) test('T10313', [extra_files(['Test10313.hs', 'stringSource.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory T10313']) -test('T11018', [extra_files(['Test11018.hs']), +# Stricter tests from trac #16217 now causes this to fail. Will be fixed for trac #16212 +test('T11018', [expect_broken(11018),extra_files(['Test11018.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory T11018']) test('bundle-export', [extra_files(['BundleExport.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory bundle-export']) @@ -59,3 +60,6 @@ test('T13163', [extra_files(['Test13163.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory T13163']) test('T15303', [extra_files(['Test15303.hs']), ignore_stderr], run_command, ['$MAKE -s --no-print-directory T15303']) +# Stricter tests from trac #16217 now causes this to fail. Will be fixed for trac #16212 +test('T16212', [expect_broken(16212),extra_files(['Test16212.hs']), + ignore_stderr], run_command, ['$MAKE -s --no-print-directory T16212']) diff --git a/testsuite/tests/ghc-api/annotations/boolFormula.stdout b/testsuite/tests/ghc-api/annotations/boolFormula.stdout index d816f04eb3..375f5fbe15 100644 --- a/testsuite/tests/ghc-api/annotations/boolFormula.stdout +++ b/testsuite/tests/ghc-api/annotations/boolFormula.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/bundle-export.stdout b/testsuite/tests/ghc-api/annotations/bundle-export.stdout index b3a02a698c..be12307c6c 100644 --- a/testsuite/tests/ghc-api/annotations/bundle-export.stdout +++ b/testsuite/tests/ghc-api/annotations/bundle-export.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/exampleTest.stdout b/testsuite/tests/ghc-api/annotations/exampleTest.stdout index 2cdef957d3..dc6cd441dc 100644 --- a/testsuite/tests/ghc-api/annotations/exampleTest.stdout +++ b/testsuite/tests/ghc-api/annotations/exampleTest.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/testsuite/tests/ghc-api/annotations/load-main.stdout b/testsuite/tests/ghc-api/annotations/load-main.stdout index b12cec2656..8891fdf516 100644 --- a/testsuite/tests/ghc-api/annotations/load-main.stdout +++ b/testsuite/tests/ghc-api/annotations/load-main.stdout @@ -1,5 +1,10 @@ ----Problems (should be empty list)--- +---Unattached Annotation Problems (should be empty list)--- [] +---Ann before enclosing span problem (should be empty list)--- +[ + +] + ---Annotations----------------------- -- SrcSpan the annotation is attached to, AnnKeywordId, -- list of locations the keyword item appears in diff --git a/utils/check-api-annotations/Main.hs b/utils/check-api-annotations/Main.hs index 6b973e12e8..2597f5ec56 100644 --- a/utils/check-api-annotations/Main.hs +++ b/utils/check-api-annotations/Main.hs @@ -53,14 +53,24 @@ testOneFile libdir fileName = do problems'' = filter (\((a,_),_) -> a /= AnnEofPos) problems' - putStrLn "---Problems (should be empty list)---" + -- Check that every annotation location in 'vs' appears after + -- the start of the enclosing span 's' + comesBefore ((s,k),vs) = not $ all ok vs + where + ok v = (k == AnnEofPos) || (srcSpanStart s <= srcSpanStart v) + + precedingProblems = filter comesBefore $ Map.toList anns + + putStrLn "---Unattached Annotation Problems (should be empty list)---" putStrLn (intercalate "\n" [pp $ Map.fromList $ map fst problems'']) + putStrLn "---Ann before enclosing span problem (should be empty list)---" + putStrLn (showAnnsList precedingProblems) putStrLn "---Annotations-----------------------" putStrLn "-- SrcSpan the annotation is attached to, AnnKeywordId," putStrLn "-- list of locations the keyword item appears in" -- putStrLn (intercalate "\n" [showAnns anns]) putStrLn (showAnns anns) - if null problems'' + if null problems'' && null precedingProblems then exitSuccess else exitFailure @@ -73,11 +83,13 @@ testOneFile libdir fileName = do showAnns :: Map.Map ApiAnnKey [SrcSpan] -> String -showAnns anns = "[\n" ++ (intercalate ",\n" +showAnns anns = showAnnsList $ Map.toList anns + +showAnnsList :: [(ApiAnnKey, [SrcSpan])] -> String +showAnnsList annsList = "[\n" ++ (intercalate ",\n" $ map (\((s,k),v) - -- -> ("(AK " ++ pp s ++ " " ++ show k ++" = " ++ pp v ++ ")\n")) -> ("((" ++ pp s ++ "," ++ show k ++"), " ++ pp v ++ ")")) - $ Map.toList anns) + annsList) ++ "\n]\n" pp :: (Outputable a) => a -> String |