diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-02-16 13:19:51 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-21 20:45:59 -0500 |
commit | be7068a6130f394dcefbcb5d09c2944deca2270d (patch) | |
tree | 7cebbd7dfa58087696b23335bce466104e97c317 /testsuite/tests/ghc-api | |
parent | 0482f58ab0490b2394ad60946dde3214a0ca1810 (diff) | |
download | haskell-be7068a6130f394dcefbcb5d09c2944deca2270d.tar.gz |
Parser API annotations: RealSrcLoc
During parsing, GHC collects lexical information about AST nodes and
stores it in a map. It is needed to faithfully restore original source
code, e.g. compare these expressions:
a = b
a = b
The position of the equality sign is not recorded in the AST, so it must
be stored elsewhere.
This system is described in Note [Api annotations].
Before this patch, the mapping was represented by:
Map (SrcSpan, AnnKeywordId) SrcSpan
After this patch, the mapping is represented by:
Map (RealSrcSpan, AnnKeywordId) RealSrcSpan
The motivation behind this change is to avoid using the Ord SrcSpan
instance (required by Map here), as it interferes with #17632 (see the
discussion there).
SrcSpan is isomorphic to Either String RealSrcSpan, but we shouldn't
use those strings as Map keys. Those strings are intended as hints to
the user, e.g. "<interactive>" or "<compiler-generated code>", so they
are not a valid way to identify nodes in the source code.
Diffstat (limited to 'testsuite/tests/ghc-api')
41 files changed, 149 insertions, 101 deletions
diff --git a/testsuite/tests/ghc-api/annotations/StarBinderAnns.stdout b/testsuite/tests/ghc-api/annotations/StarBinderAnns.stdout index d75f30a9d8..9d063f0934 100644 --- a/testsuite/tests/ghc-api/annotations/StarBinderAnns.stdout +++ b/testsuite/tests/ghc-api/annotations/StarBinderAnns.stdout @@ -31,6 +31,8 @@ ((StarBinderAnns.hs:6:29-31,AnnOpenP), [StarBinderAnns.hs:6:29]), ((StarBinderAnns.hs:6:29-48,AnnCloseP), [StarBinderAnns.hs:6:31]), ((StarBinderAnns.hs:6:29-48,AnnEqual), [StarBinderAnns.hs:6:37]), -((StarBinderAnns.hs:6:29-48,AnnOpenP), [StarBinderAnns.hs:6:29]), -((<no location info>,AnnEofPos), [StarBinderAnns.hs:7:1]) -]
\ No newline at end of file +((StarBinderAnns.hs:6:29-48,AnnOpenP), [StarBinderAnns.hs:6:29]) +] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "StarBinderAnns.hs" 7 1 diff --git a/testsuite/tests/ghc-api/annotations/T10255.stdout b/testsuite/tests/ghc-api/annotations/T10255.stdout index 60e632a3e8..15df1b7f44 100644 --- a/testsuite/tests/ghc-api/annotations/T10255.stdout +++ b/testsuite/tests/ghc-api/annotations/T10255.stdout @@ -22,7 +22,8 @@ ((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]) +((Test10255.hs:6:12-25,AnnRarrow), [Test10255.hs:6:20-21]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10255.hs" 8 1 diff --git a/testsuite/tests/ghc-api/annotations/T10268.stdout b/testsuite/tests/ghc-api/annotations/T10268.stdout index 502d5fcf47..906632a59b 100644 --- a/testsuite/tests/ghc-api/annotations/T10268.stdout +++ b/testsuite/tests/ghc-api/annotations/T10268.stdout @@ -32,7 +32,8 @@ ((Test10268.hs:10:18-20,AnnSimpleQuote), [Test10268.hs:10:18]), ((Test10268.hs:11:1-17,AnnEqual), [Test10268.hs:11:7]), ((Test10268.hs:11:1-17,AnnFunId), [Test10268.hs:11:1-5]), -((Test10268.hs:11:1-17,AnnSemi), [Test10268.hs:12:1]), -((<no location info>,AnnEofPos), [Test10268.hs:12:1]) +((Test10268.hs:11:1-17,AnnSemi), [Test10268.hs:12:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10268.hs" 12 1 diff --git a/testsuite/tests/ghc-api/annotations/T10269.stdout b/testsuite/tests/ghc-api/annotations/T10269.stdout index f0589a0551..b0946e1812 100644 --- a/testsuite/tests/ghc-api/annotations/T10269.stdout +++ b/testsuite/tests/ghc-api/annotations/T10269.stdout @@ -18,7 +18,8 @@ ((Test10269.hs:4:1-26,AnnFunId), [Test10269.hs:4:4-6]), ((Test10269.hs:4:1-26,AnnOpenP), [Test10269.hs:4:1]), ((Test10269.hs:4:1-26,AnnSemi), [Test10269.hs:5:1]), -((Test10269.hs:4:2-8,AnnVal), [Test10269.hs:4:4-6]), -((<no location info>,AnnEofPos), [Test10269.hs:5:1]) +((Test10269.hs:4:2-8,AnnVal), [Test10269.hs:4:4-6]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10269.hs" 5 1 diff --git a/testsuite/tests/ghc-api/annotations/T10276.stdout b/testsuite/tests/ghc-api/annotations/T10276.stdout index 77b2dae7a2..4c53170e2c 100644 --- a/testsuite/tests/ghc-api/annotations/T10276.stdout +++ b/testsuite/tests/ghc-api/annotations/T10276.stdout @@ -64,7 +64,8 @@ ((Test10276.hs:15:41-70,AnnOpenP), [Test10276.hs:15:41]), ((Test10276.hs:15:42-44,AnnComma), [Test10276.hs:15:45]), ((Test10276.hs:15:59-69,AnnCloseS), [Test10276.hs:15:69]), -((Test10276.hs:15:59-69,AnnOpenS), [Test10276.hs:15:59]), -((<no location info>,AnnEofPos), [Test10276.hs:16:1]) +((Test10276.hs:15:59-69,AnnOpenS), [Test10276.hs:15:59]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10276.hs" 16 1 diff --git a/testsuite/tests/ghc-api/annotations/T10278.stdout b/testsuite/tests/ghc-api/annotations/T10278.stdout index dd6fa432de..7c029c6c06 100644 --- a/testsuite/tests/ghc-api/annotations/T10278.stdout +++ b/testsuite/tests/ghc-api/annotations/T10278.stdout @@ -92,7 +92,8 @@ ((Test10278.hs:17:56-57,AnnRarrow), [Test10278.hs:17:59-60]), ((Test10278.hs:17:56-80,AnnRarrow), [Test10278.hs:17:59-60]), ((Test10278.hs:17:62,AnnRarrow), [Test10278.hs:17:64-65]), -((Test10278.hs:17:62-80,AnnRarrow), [Test10278.hs:17:64-65]), -((<no location info>,AnnEofPos), [Test10278.hs:21:1]) +((Test10278.hs:17:62-80,AnnRarrow), [Test10278.hs:17:64-65]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10278.hs" 21 1 diff --git a/testsuite/tests/ghc-api/annotations/T10280.stdout b/testsuite/tests/ghc-api/annotations/T10280.stdout index aa488a4ae3..e291777a0e 100644 --- a/testsuite/tests/ghc-api/annotations/T10280.stdout +++ b/testsuite/tests/ghc-api/annotations/T10280.stdout @@ -21,7 +21,8 @@ ((Test10280.hs:4:36-44,AnnVal), [Test10280.hs:4:42]), ((Test10280.hs:4:37,AnnComma), [Test10280.hs:4:37]), ((Test10280.hs:4:38-39,AnnCloseP), [Test10280.hs:4:39]), -((Test10280.hs:4:38-39,AnnOpenP), [Test10280.hs:4:38]), -((<no location info>,AnnEofPos), [Test10280.hs:5:1]) +((Test10280.hs:4:38-39,AnnOpenP), [Test10280.hs:4:38]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10280.hs" 5 1 diff --git a/testsuite/tests/ghc-api/annotations/T10307.stdout b/testsuite/tests/ghc-api/annotations/T10307.stdout index 47c995d84b..163bfb6b82 100644 --- a/testsuite/tests/ghc-api/annotations/T10307.stdout +++ b/testsuite/tests/ghc-api/annotations/T10307.stdout @@ -21,7 +21,8 @@ ((Test10307.hs:6:3-34,AnnType), [Test10307.hs:6:3-6]), ((Test10307.hs:6:8-34,AnnEqual), [Test10307.hs:6:31]), ((Test10307.hs:6:33-34,AnnCloseP), [Test10307.hs:6:34]), -((Test10307.hs:6:33-34,AnnOpenP), [Test10307.hs:6:33]), -((<no location info>,AnnEofPos), [Test10307.hs:7:1]) +((Test10307.hs:6:33-34,AnnOpenP), [Test10307.hs:6:33]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10307.hs" 7 1 diff --git a/testsuite/tests/ghc-api/annotations/T10309.stdout b/testsuite/tests/ghc-api/annotations/T10309.stdout index 332220a3ba..a929c1b70c 100644 --- a/testsuite/tests/ghc-api/annotations/T10309.stdout +++ b/testsuite/tests/ghc-api/annotations/T10309.stdout @@ -22,7 +22,8 @@ ((Test10309.hs:(5,20)-(6,20),AnnOpenC), [Test10309.hs:5:20]), ((Test10309.hs:(5,20)-(6,20),AnnRarrow), [Test10309.hs:6:22-23]), ((Test10309.hs:(5,20)-(6,34),AnnRarrow), [Test10309.hs:6:22-23]), -((Test10309.hs:5:22-31,AnnDcolon), [Test10309.hs:5:28-29]), -((<no location info>,AnnEofPos), [Test10309.hs:7:1]) +((Test10309.hs:5:22-31,AnnDcolon), [Test10309.hs:5:28-29]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10309.hs" 7 1 diff --git a/testsuite/tests/ghc-api/annotations/T10312.stdout b/testsuite/tests/ghc-api/annotations/T10312.stdout index 3627d0b2c2..5a46df4f86 100644 --- a/testsuite/tests/ghc-api/annotations/T10312.stdout +++ b/testsuite/tests/ghc-api/annotations/T10312.stdout @@ -251,7 +251,8 @@ ((Test10312.hs:78:42-53,AnnFunId), [Test10312.hs:78:42-43]), ((Test10312.hs:79:57-62,AnnCloseP), [Test10312.hs:79:62]), ((Test10312.hs:79:57-62,AnnOpenP), [Test10312.hs:79:57]), -((Test10312.hs:79:58,AnnComma), [Test10312.hs:79:59]), -((<no location info>,AnnEofPos), [Test10312.hs:80:1]) +((Test10312.hs:79:58,AnnComma), [Test10312.hs:79:59]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10312.hs" 80 1 diff --git a/testsuite/tests/ghc-api/annotations/T10354.stdout b/testsuite/tests/ghc-api/annotations/T10354.stdout index 8f00de0f51..7fbc54d49c 100644 --- a/testsuite/tests/ghc-api/annotations/T10354.stdout +++ b/testsuite/tests/ghc-api/annotations/T10354.stdout @@ -50,7 +50,8 @@ ((Test10354.hs:13:1-17,AnnSemi), [Test10354.hs:14:1]), ((Test10354.hs:14:1-15,AnnEqual), [Test10354.hs:14:5]), ((Test10354.hs:14:1-15,AnnFunId), [Test10354.hs:14:1-3]), -((Test10354.hs:14:1-15,AnnSemi), [Test10354.hs:15:1]), -((<no location info>,AnnEofPos), [Test10354.hs:15:1]) +((Test10354.hs:14:1-15,AnnSemi), [Test10354.hs:15:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10354.hs" 15 1 diff --git a/testsuite/tests/ghc-api/annotations/T10357.stdout b/testsuite/tests/ghc-api/annotations/T10357.stdout index 3d4bcd1fc9..4810a59cd7 100644 --- a/testsuite/tests/ghc-api/annotations/T10357.stdout +++ b/testsuite/tests/ghc-api/annotations/T10357.stdout @@ -57,7 +57,8 @@ ((Test10357.hs:10:27-44,AnnFunId), [Test10357.hs:10:27-28]), ((Test10357.hs:11:7-29,AnnLarrow), [Test10357.hs:11:13-14]), ((Test10357.hs:11:7-29,AnnVbar), [Test10357.hs:12:5]), -((Test10357.hs:12:7-24,AnnLarrow), [Test10357.hs:12:13-14]), -((<no location info>,AnnEofPos), [Test10357.hs:14:1]) +((Test10357.hs:12:7-24,AnnLarrow), [Test10357.hs:12:13-14]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10357.hs" 14 1 diff --git a/testsuite/tests/ghc-api/annotations/T10358.stdout b/testsuite/tests/ghc-api/annotations/T10358.stdout index 28f516cb5e..2216c8396e 100644 --- a/testsuite/tests/ghc-api/annotations/T10358.stdout +++ b/testsuite/tests/ghc-api/annotations/T10358.stdout @@ -33,7 +33,8 @@ ((Test10358.hs:6:12-16,AnnVal), [Test10358.hs:6:15]), ((Test10358.hs:7:7-17,AnnEqual), [Test10358.hs:7:10]), ((Test10358.hs:7:7-17,AnnFunId), [Test10358.hs:7:7-8]), -((Test10358.hs:7:12-17,AnnVal), [Test10358.hs:7:14]), -((<no location info>,AnnEofPos), [Test10358.hs:9:1]) +((Test10358.hs:7:12-17,AnnVal), [Test10358.hs:7:14]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10358.hs" 9 1 diff --git a/testsuite/tests/ghc-api/annotations/T10396.stdout b/testsuite/tests/ghc-api/annotations/T10396.stdout index 2f7b8848b4..32dadc3d95 100644 --- a/testsuite/tests/ghc-api/annotations/T10396.stdout +++ b/testsuite/tests/ghc-api/annotations/T10396.stdout @@ -24,7 +24,8 @@ ((Test10396.hs:6:7-15,AnnDcolon), [Test10396.hs:6:10-11]), ((Test10396.hs:6:7-27,AnnEqual), [Test10396.hs:6:17]), ((Test10396.hs:7:10-11,AnnCloseP), [Test10396.hs:7:11]), -((Test10396.hs:7:10-11,AnnOpenP), [Test10396.hs:7:10]), -((<no location info>,AnnEofPos), [Test10396.hs:8:1]) +((Test10396.hs:7:10-11,AnnOpenP), [Test10396.hs:7:10]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10396.hs" 8 1 diff --git a/testsuite/tests/ghc-api/annotations/T10399.stdout b/testsuite/tests/ghc-api/annotations/T10399.stdout index b1e5a34d8f..a71abc4139 100644 --- a/testsuite/tests/ghc-api/annotations/T10399.stdout +++ b/testsuite/tests/ghc-api/annotations/T10399.stdout @@ -90,7 +90,8 @@ ((Test10399.hs:22:6-17,AnnCloseP), [Test10399.hs:22:17]), ((Test10399.hs:22:6-17,AnnOpenP), [Test10399.hs:22:6]), ((Test10399.hs:22:8-15,AnnCloseQ), [Test10399.hs:22:14-15]), -((Test10399.hs:22:8-15,AnnOpen), [Test10399.hs:22:8-10]), -((<no location info>,AnnEofPos), [Test10399.hs:23:1]) +((Test10399.hs:22:8-15,AnnOpen), [Test10399.hs:22:8-10]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10399.hs" 23 1 diff --git a/testsuite/tests/ghc-api/annotations/T10598.stdout b/testsuite/tests/ghc-api/annotations/T10598.stdout index 61d762ce7f..b2d9333bf2 100644 --- a/testsuite/tests/ghc-api/annotations/T10598.stdout +++ b/testsuite/tests/ghc-api/annotations/T10598.stdout @@ -36,7 +36,8 @@ ((Test10598.hs:18:1-34,AnnDeriving), [Test10598.hs:18:1-8]), ((Test10598.hs:18:1-34,AnnInstance), [Test10598.hs:18:18-25]), ((Test10598.hs:18:1-34,AnnSemi), [Test10598.hs:19:1]), -((Test10598.hs:18:10-16,AnnNewtype), [Test10598.hs:18:10-16]), -((<no location info>,AnnEofPos), [Test10598.hs:19:1]) +((Test10598.hs:18:10-16,AnnNewtype), [Test10598.hs:18:10-16]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test10598.hs" 19 1 diff --git a/testsuite/tests/ghc-api/annotations/T11018.stdout b/testsuite/tests/ghc-api/annotations/T11018.stdout index 4640e33690..27cc80ae6f 100644 --- a/testsuite/tests/ghc-api/annotations/T11018.stdout +++ b/testsuite/tests/ghc-api/annotations/T11018.stdout @@ -210,7 +210,8 @@ ((Test11018.hs:52:14-18,AnnOpenP), [Test11018.hs:52:14]), ((Test11018.hs:52:15,AnnComma), [Test11018.hs:52:16]), ((Test11018.hs:52:23-29,AnnRarrowtailU), [Test11018.hs:52:25]), -((Test11018.hs:52:27-29,AnnVal), [Test11018.hs:52:28]), -((<no location info>,AnnEofPos), [Test11018.hs:53:1]) +((Test11018.hs:52:27-29,AnnVal), [Test11018.hs:52:28]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test11018.hs" 53 1 diff --git a/testsuite/tests/ghc-api/annotations/T11321.stdout b/testsuite/tests/ghc-api/annotations/T11321.stdout index 1fe2dbe301..15d2169dba 100644 --- a/testsuite/tests/ghc-api/annotations/T11321.stdout +++ b/testsuite/tests/ghc-api/annotations/T11321.stdout @@ -42,7 +42,8 @@ ((Test11321.hs:17:11-18,AnnCloseP), [Test11321.hs:17:18]), ((Test11321.hs:17:11-18,AnnOpenP), [Test11321.hs:17:11]), ((Test11321.hs:17:20-27,AnnCloseP), [Test11321.hs:17:27]), -((Test11321.hs:17:20-27,AnnOpenP), [Test11321.hs:17:20]), -((<no location info>,AnnEofPos), [Test11321.hs:18:1]) +((Test11321.hs:17:20-27,AnnOpenP), [Test11321.hs:17:20]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test11321.hs" 18 1 diff --git a/testsuite/tests/ghc-api/annotations/T11332.stdout b/testsuite/tests/ghc-api/annotations/T11332.stdout index 20fcfa98fb..bdb849e680 100644 --- a/testsuite/tests/ghc-api/annotations/T11332.stdout +++ b/testsuite/tests/ghc-api/annotations/T11332.stdout @@ -49,7 +49,8 @@ ((Test11332.hs:15:1-13,AnnSemi), [Test11332.hs:17:1]), ((Test11332.hs:17:1-13,AnnEqual), [Test11332.hs:17:11]), ((Test11332.hs:17:1-13,AnnPattern), [Test11332.hs:17:1-7]), -((Test11332.hs:17:1-13,AnnSemi), [Test11332.hs:18:1]), -((<no location info>,AnnEofPos), [Test11332.hs:18:1]) +((Test11332.hs:17:1-13,AnnSemi), [Test11332.hs:18:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test11332.hs" 18 1 diff --git a/testsuite/tests/ghc-api/annotations/T12417.stdout b/testsuite/tests/ghc-api/annotations/T12417.stdout index cc81e6e0b8..2cfd3c0635 100644 --- a/testsuite/tests/ghc-api/annotations/T12417.stdout +++ b/testsuite/tests/ghc-api/annotations/T12417.stdout @@ -69,7 +69,8 @@ ((Test12417.hs:19:13-31,AnnOpen), [Test12417.hs:19:13-14]), ((Test12417.hs:19:13-31,AnnVbar), [Test12417.hs:19:16, Test12417.hs:19:20, Test12417.hs:19:22, Test12417.hs:19:24, Test12417.hs:19:26, Test12417.hs:19:28]), -((Test12417.hs:19:35-52,AnnVal), [Test12417.hs:19:44-45]), -((<no location info>,AnnEofPos), [Test12417.hs:20:1]) +((Test12417.hs:19:35-52,AnnVal), [Test12417.hs:19:44-45]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test12417.hs" 20 1 diff --git a/testsuite/tests/ghc-api/annotations/T13163.stdout b/testsuite/tests/ghc-api/annotations/T13163.stdout index 99680d1bad..60b89cd832 100644 --- a/testsuite/tests/ghc-api/annotations/T13163.stdout +++ b/testsuite/tests/ghc-api/annotations/T13163.stdout @@ -77,7 +77,8 @@ ((Test13163.hs:14:20-22,AnnOpenS), [Test13163.hs:14:20]), ((Test13163.hs:16:1-13,AnnEqual), [Test13163.hs:16:3]), ((Test13163.hs:16:1-13,AnnFunId), [Test13163.hs:16:1]), -((Test13163.hs:16:1-13,AnnSemi), [Test13163.hs:17:1]), -((<no location info>,AnnEofPos), [Test13163.hs:17:1]) +((Test13163.hs:16:1-13,AnnSemi), [Test13163.hs:17:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test13163.hs" 17 1 diff --git a/testsuite/tests/ghc-api/annotations/T15303.stdout b/testsuite/tests/ghc-api/annotations/T15303.stdout index e571918eba..84d592dd0e 100644 --- a/testsuite/tests/ghc-api/annotations/T15303.stdout +++ b/testsuite/tests/ghc-api/annotations/T15303.stdout @@ -35,6 +35,8 @@ ((Test15303.hs:5:1-15,AnnSemi), [Test15303.hs:6:1]), ((Test15303.hs:6:1-11,AnnInfix), [Test15303.hs:6:1-6]), ((Test15303.hs:6:1-11,AnnSemi), [Test15303.hs:7:1]), -((Test15303.hs:6:1-11,AnnVal), [Test15303.hs:6:8]), -((<no location info>,AnnEofPos), [Test15303.hs:7:1]) +((Test15303.hs:6:1-11,AnnVal), [Test15303.hs:6:8]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test15303.hs" 7 1 diff --git a/testsuite/tests/ghc-api/annotations/T16212.stdout b/testsuite/tests/ghc-api/annotations/T16212.stdout index d4f0f08d89..ec1932ed42 100644 --- a/testsuite/tests/ghc-api/annotations/T16212.stdout +++ b/testsuite/tests/ghc-api/annotations/T16212.stdout @@ -61,6 +61,8 @@ ((Test16212.hs:13:22-41,AnnOpenC), [Test16212.hs:13:22]), ((Test16212.hs:13:24-30,AnnComma), [Test16212.hs:13:31]), ((Test16212.hs:13:24-30,AnnDcolon), [Test16212.hs:13:27-28]), -((Test16212.hs:13:33-39,AnnDcolon), [Test16212.hs:13:36-37]), -((<no location info>,AnnEofPos), [Test16212.hs:14:1]) +((Test16212.hs:13:33-39,AnnDcolon), [Test16212.hs:13:36-37]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test16212.hs" 14 1 diff --git a/testsuite/tests/ghc-api/annotations/T16230.stdout b/testsuite/tests/ghc-api/annotations/T16230.stdout index af1d96395e..5af52f6a50 100644 --- a/testsuite/tests/ghc-api/annotations/T16230.stdout +++ b/testsuite/tests/ghc-api/annotations/T16230.stdout @@ -61,6 +61,8 @@ ((Test16230.hs:22:21-29,AnnOpenP), [Test16230.hs:22:21]), ((Test16230.hs:23:3-36,AnnDot), [Test16230.hs:23:11]), ((Test16230.hs:23:3-36,AnnEqual), [Test16230.hs:23:31]), -((Test16230.hs:23:3-36,AnnForall), [Test16230.hs:23:3-8]), -((<no location info>,AnnEofPos), [Test16230.hs:24:1]) +((Test16230.hs:23:3-36,AnnForall), [Test16230.hs:23:3-8]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test16230.hs" 24 1 diff --git a/testsuite/tests/ghc-api/annotations/T16236.stdout b/testsuite/tests/ghc-api/annotations/T16236.stdout index 986b9a4ff2..8ca1725440 100644 --- a/testsuite/tests/ghc-api/annotations/T16236.stdout +++ b/testsuite/tests/ghc-api/annotations/T16236.stdout @@ -80,6 +80,8 @@ ((Test16236.hs:20:20-37,AnnCloseP), [Test16236.hs:20:37]), ((Test16236.hs:20:20-37,AnnOpenP), [Test16236.hs:20:20]), ((Test16236.hs:20:21-26,AnnRarrow), [Test16236.hs:20:28-29]), -((Test16236.hs:20:21-36,AnnRarrow), [Test16236.hs:20:28-29]), -((<no location info>,AnnEofPos), [Test16236.hs:21:1]) +((Test16236.hs:20:21-36,AnnRarrow), [Test16236.hs:20:28-29]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test16236.hs" 21 1 diff --git a/testsuite/tests/ghc-api/annotations/T16279.stdout b/testsuite/tests/ghc-api/annotations/T16279.stdout index 7dac950679..901c776fdd 100644 --- a/testsuite/tests/ghc-api/annotations/T16279.stdout +++ b/testsuite/tests/ghc-api/annotations/T16279.stdout @@ -25,6 +25,8 @@ ((Test16279.hs:9:1-16,AnnFunId), [Test16279.hs:9:1-4]), ((Test16279.hs:9:1-16,AnnSemi), [Test16279.hs:11:1]), ((Test16279.hs:9:15-16,AnnCloseP), [Test16279.hs:9:16]), -((Test16279.hs:9:15-16,AnnOpenP), [Test16279.hs:9:15]), -((<no location info>,AnnEofPos), [Test16279.hs:11:1]) -]
\ No newline at end of file +((Test16279.hs:9:15-16,AnnOpenP), [Test16279.hs:9:15]) +] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test16279.hs" 11 1 diff --git a/testsuite/tests/ghc-api/annotations/T17388.stdout b/testsuite/tests/ghc-api/annotations/T17388.stdout index 2a43489521..b2012bff79 100644 --- a/testsuite/tests/ghc-api/annotations/T17388.stdout +++ b/testsuite/tests/ghc-api/annotations/T17388.stdout @@ -28,6 +28,8 @@ ((Test17388.hs:9:1-50,AnnOpen), [Test17388.hs:9:8-17]), ((Test17388.hs:9:1-50,AnnPackageName), [Test17388.hs:9:34-39]), ((Test17388.hs:9:1-50,AnnQualified), [Test17388.hs:9:23-31]), -((Test17388.hs:9:1-50,AnnSemi), [Test17388.hs:10:1]), -((<no location info>,AnnEofPos), [Test17388.hs:10:1]) +((Test17388.hs:9:1-50,AnnSemi), [Test17388.hs:10:1]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test17388.hs" 10 1 diff --git a/testsuite/tests/ghc-api/annotations/T17519.stdout b/testsuite/tests/ghc-api/annotations/T17519.stdout index e71dd7f1a0..9560a68675 100644 --- a/testsuite/tests/ghc-api/annotations/T17519.stdout +++ b/testsuite/tests/ghc-api/annotations/T17519.stdout @@ -20,6 +20,8 @@ ((Test17519.hs:5:23-36,AnnRarrowU), [Test17519.hs:5:27]), ((Test17519.hs:5:29,AnnRarrowU), [Test17519.hs:5:31]), ((Test17519.hs:5:29-36,AnnRarrowU), [Test17519.hs:5:31]), -((Test17519.hs:6:3-18,AnnEqual), [Test17519.hs:6:11]), -((<no location info>,AnnEofPos), [Test17519.hs:7:1]) +((Test17519.hs:6:3-18,AnnEqual), [Test17519.hs:6:11]) ] + +---Eof Position (should be Just)----- +Just SrcSpanPoint "Test17519.hs" 7 1 diff --git a/testsuite/tests/ghc-api/annotations/annotations.hs b/testsuite/tests/ghc-api/annotations/annotations.hs index 9ea0c0c004..a9d54a422b 100644 --- a/testsuite/tests/ghc-api/annotations/annotations.hs +++ b/testsuite/tests/ghc-api/annotations/annotations.hs @@ -43,13 +43,16 @@ testOneFile libdir fileName = do return (pm_annotations p) let anns = p - (l,_) = fst $ head $ Map.toList (fst anns) - annModule = (getAnnotation anns l AnnModule) - annLet = (getAnnotation anns l AnnLet) + ann_items = apiAnnItems anns + ann_eof = apiAnnEofPos anns + (l,_) = fst $ head $ Map.toList ann_items + annModule = getAnnotation anns l AnnModule + annLet = getAnnotation anns l AnnLet - putStrLn (intercalate "\n" [showAnns anns,pp annModule,pp annLet,pp l]) + putStrLn (intercalate "\n" [showAnns ann_items,pp annModule,pp annLet,pp l, + "EOF: " ++ show ann_eof]) -showAnns (anns,_) = "[\n" ++ (intercalate "\n" +showAnns anns = "[\n" ++ (intercalate "\n" $ map (\((s,k),v) -> ("(AK " ++ pp s ++ " " ++ show k ++" = " ++ pp v ++ ")\n")) $ Map.toList anns) diff --git a/testsuite/tests/ghc-api/annotations/annotations.stdout b/testsuite/tests/ghc-api/annotations/annotations.stdout index f0348058ba..fbc028a56f 100644 --- a/testsuite/tests/ghc-api/annotations/annotations.stdout +++ b/testsuite/tests/ghc-api/annotations/annotations.stdout @@ -78,10 +78,9 @@ (AK AnnotationLet.hs:15:36-40 AnnCloseP = [AnnotationLet.hs:15:40]) (AK AnnotationLet.hs:15:36-40 AnnOpenP = [AnnotationLet.hs:15:36]) - -(AK <no location info> AnnEofPos = [AnnotationLet.hs:18:1]) ] [AnnotationLet.hs:2:1-6] [] AnnotationLet.hs:1:1 +EOF: Just SrcSpanPoint "./AnnotationLet.hs" 18 1 diff --git a/testsuite/tests/ghc-api/annotations/boolFormula.stdout b/testsuite/tests/ghc-api/annotations/boolFormula.stdout index 375f5fbe15..3c425811b4 100644 --- a/testsuite/tests/ghc-api/annotations/boolFormula.stdout +++ b/testsuite/tests/ghc-api/annotations/boolFormula.stdout @@ -146,7 +146,8 @@ ((TestBoolFormula.hs:35:5-20,AnnFunId), [TestBoolFormula.hs:35:5-8]), ((TestBoolFormula.hs:35:5-20,AnnSemi), [TestBoolFormula.hs:36:5]), ((TestBoolFormula.hs:36:5-19,AnnEqual), [TestBoolFormula.hs:36:9]), -((TestBoolFormula.hs:36:5-19,AnnFunId), [TestBoolFormula.hs:36:5-7]), -((<no location info>,AnnEofPos), [TestBoolFormula.hs:37:1]) +((TestBoolFormula.hs:36:5-19,AnnFunId), [TestBoolFormula.hs:36:5-7]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "TestBoolFormula.hs" 37 1 diff --git a/testsuite/tests/ghc-api/annotations/bundle-export.stdout b/testsuite/tests/ghc-api/annotations/bundle-export.stdout index be12307c6c..e7bff3db75 100644 --- a/testsuite/tests/ghc-api/annotations/bundle-export.stdout +++ b/testsuite/tests/ghc-api/annotations/bundle-export.stdout @@ -30,7 +30,8 @@ ((BundleExport.hs:8:1-13,AnnSemi), [BundleExport.hs:9:1]), ((BundleExport.hs:9:1-13,AnnEqual), [BundleExport.hs:9:11]), ((BundleExport.hs:9:1-13,AnnPattern), [BundleExport.hs:9:1-7]), -((BundleExport.hs:9:1-13,AnnSemi), [BundleExport.hs:10:1]), -((<no location info>,AnnEofPos), [BundleExport.hs:10:1]) +((BundleExport.hs:9:1-13,AnnSemi), [BundleExport.hs:10:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "BundleExport.hs" 10 1 diff --git a/testsuite/tests/ghc-api/annotations/comments.hs b/testsuite/tests/ghc-api/annotations/comments.hs index 585e4f91eb..128a69f15e 100644 --- a/testsuite/tests/ghc-api/annotations/comments.hs +++ b/testsuite/tests/ghc-api/annotations/comments.hs @@ -49,13 +49,19 @@ testOneFile libdir fileName useHaddock = do return (pm_annotations p) let anns = p + ann_comments = apiAnnComments anns + ann_rcomments = apiAnnRogueComments anns + comments = + map (\(s,v) -> (RealSrcSpan s, v)) (Map.toList ann_comments) + ++ + [(noSrcSpan, ann_rcomments)] - putStrLn (intercalate "\n" [showAnns anns]) + putStrLn (intercalate "\n" [showAnns comments]) -showAnns (_,anns) = "[\n" ++ (intercalate "\n" +showAnns anns = "[\n" ++ (intercalate "\n" $ map (\(s,v) -> ("( " ++ pp s ++" =\n[" ++ showToks v ++ "])\n")) - $ Map.toList anns) + $ anns) ++ "]\n" showToks ts = intercalate ",\n\n" diff --git a/testsuite/tests/ghc-api/annotations/exampleTest.stdout b/testsuite/tests/ghc-api/annotations/exampleTest.stdout index dc6cd441dc..904b845bfd 100644 --- a/testsuite/tests/ghc-api/annotations/exampleTest.stdout +++ b/testsuite/tests/ghc-api/annotations/exampleTest.stdout @@ -81,7 +81,8 @@ ((AnnotationTuple.hs:22:9-25,AnnLarrow), [AnnotationTuple.hs:22:16-17]), ((AnnotationTuple.hs:23:9-24,AnnLarrow), [AnnotationTuple.hs:23:16-17]), ((AnnotationTuple.hs:26:1-10,AnnDcolon), [AnnotationTuple.hs:26:5-6]), -((AnnotationTuple.hs:26:1-14,AnnEqual), [AnnotationTuple.hs:26:12]), -((<no location info>,AnnEofPos), [AnnotationTuple.hs:32:1]) +((AnnotationTuple.hs:26:1-14,AnnEqual), [AnnotationTuple.hs:26:12]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "AnnotationTuple.hs" 32 1 diff --git a/testsuite/tests/ghc-api/annotations/listcomps.hs b/testsuite/tests/ghc-api/annotations/listcomps.hs index 7274e981cc..313da7c750 100644 --- a/testsuite/tests/ghc-api/annotations/listcomps.hs +++ b/testsuite/tests/ghc-api/annotations/listcomps.hs @@ -29,7 +29,7 @@ main = do exitSuccess testOneFile libdir fileName = do - ((anns,cs),p) <- runGhc (Just libdir) $ do + p <- runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags let mn =mkModuleName fileName @@ -42,25 +42,27 @@ testOneFile libdir fileName = do t <- typecheckModule p d <- desugarModule t l <- loadModule d - let ts=typecheckedSource l - r =renamedSource l - return (pm_annotations p,p) + return p + let anns = pm_annotations p + ann_items = apiAnnItems anns + ann_eof = apiAnnEofPos anns let spans = Set.fromList $ getAllSrcSpans (pm_parsed_source p) putStrLn (pp spans) putStrLn "--------------------------------" - putStrLn (intercalate "\n" [showAnns anns]) + putStrLn (intercalate "\n" [showAnns ann_items,"EOF: " ++ show ann_eof]) where - getAnnSrcSpans :: ApiAnns -> [(SrcSpan,(ApiAnnKey,[SrcSpan]))] - getAnnSrcSpans (anns,_) = map (\a@((ss,_),_) -> (ss,a)) $ Map.toList anns + getAnnSrcSpans :: ApiAnns -> [(RealSrcSpan,(ApiAnnKey,[RealSrcSpan]))] + getAnnSrcSpans anns = map (\a@((ss,_),_) -> (ss,a)) $ Map.toList (apiAnnItems anns) - getAllSrcSpans :: (Data t) => t -> [SrcSpan] + getAllSrcSpans :: (Data t) => t -> [RealSrcSpan] getAllSrcSpans ast = everything (++) ([] `mkQ` getSrcSpan) ast where - getSrcSpan :: SrcSpan -> [SrcSpan] - getSrcSpan ss = [ss] + getSrcSpan :: SrcSpan -> [RealSrcSpan] + getSrcSpan (RealSrcSpan ss) = [ss] + getSrcSpan (UnhelpfulSpan _) = [] showAnns anns = "[\n" ++ (intercalate "\n" $ map (\((s,k),v) diff --git a/testsuite/tests/ghc-api/annotations/listcomps.stdout b/testsuite/tests/ghc-api/annotations/listcomps.stdout index 7b92474efb..169a1f6634 100644 --- a/testsuite/tests/ghc-api/annotations/listcomps.stdout +++ b/testsuite/tests/ghc-api/annotations/listcomps.stdout @@ -35,8 +35,7 @@ ListComprehensions.hs:(25,16)-(27,22), ListComprehensions.hs:26:16, ListComprehensions.hs:26:16-23, ListComprehensions.hs:(26,16)-(27,22), - ListComprehensions.hs:26:21-23, ListComprehensions.hs:27:21-22, - <no location info>} + ListComprehensions.hs:26:21-23, ListComprehensions.hs:27:21-22} -------------------------------- [ (AK ListComprehensions.hs:1:1 AnnModule = [ListComprehensions.hs:6:1-6]) @@ -156,7 +155,6 @@ (AK ListComprehensions.hs:26:16-23 AnnLarrow = [ListComprehensions.hs:26:18-19]) (AK ListComprehensions.hs:(26,16)-(27,22) AnnThen = [ListComprehensions.hs:27:16-19]) - -(AK <no location info> AnnEofPos = [ListComprehensions.hs:29:1]) ] +EOF: Just SrcSpanPoint "./ListComprehensions.hs" 29 1 diff --git a/testsuite/tests/ghc-api/annotations/load-main.stdout b/testsuite/tests/ghc-api/annotations/load-main.stdout index 8891fdf516..4ba092296b 100644 --- a/testsuite/tests/ghc-api/annotations/load-main.stdout +++ b/testsuite/tests/ghc-api/annotations/load-main.stdout @@ -13,7 +13,8 @@ ((load-main.hs:1:1,AnnWhere), [load-main.hs:1:13-17]), ((load-main.hs:4:1-23,AnnEqual), [load-main.hs:4:6]), ((load-main.hs:4:1-23,AnnFunId), [load-main.hs:4:1-4]), -((load-main.hs:4:1-23,AnnSemi), [load-main.hs:5:1]), -((<no location info>,AnnEofPos), [load-main.hs:5:1]) +((load-main.hs:4:1-23,AnnSemi), [load-main.hs:5:1]) ] +---Eof Position (should be Just)----- +Just SrcSpanPoint "load-main.hs" 5 1 diff --git a/testsuite/tests/ghc-api/annotations/parseTree.hs b/testsuite/tests/ghc-api/annotations/parseTree.hs index e1c75c40e2..453cade21d 100644 --- a/testsuite/tests/ghc-api/annotations/parseTree.hs +++ b/testsuite/tests/ghc-api/annotations/parseTree.hs @@ -25,7 +25,7 @@ main = do testOneFile libdir "AnnotationTuple" testOneFile libdir fileName = do - ((anns,cs),p) <- runGhc (Just libdir) $ do + p <- runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags let mn =mkModuleName fileName @@ -38,14 +38,15 @@ testOneFile libdir fileName = do t <- typecheckModule p d <- desugarModule t l <- loadModule d - let ts=typecheckedSource l - r =renamedSource l - return (pm_annotations p,p) + return p + let anns = pm_annotations p + ann_items = apiAnnItems anns + ann_eof = apiAnnEofPos anns let tupArgs = gq (pm_parsed_source p) putStrLn (pp tupArgs) - putStrLn (intercalate "\n" [showAnns anns]) + putStrLn (intercalate "\n" [showAnns ann_items, "EOF: " ++ show ann_eof]) where gq ast = everything (++) ([] `mkQ` doLHsTupArg) ast diff --git a/testsuite/tests/ghc-api/annotations/parseTree.stdout b/testsuite/tests/ghc-api/annotations/parseTree.stdout index e216ba96fa..2a53f37342 100644 --- a/testsuite/tests/ghc-api/annotations/parseTree.stdout +++ b/testsuite/tests/ghc-api/annotations/parseTree.stdout @@ -155,7 +155,6 @@ (AK AnnotationTuple.hs:26:1-10 AnnDcolon = [AnnotationTuple.hs:26:5-6]) (AK AnnotationTuple.hs:26:1-14 AnnEqual = [AnnotationTuple.hs:26:12]) - -(AK <no location info> AnnEofPos = [AnnotationTuple.hs:32:1]) ] +EOF: Just SrcSpanPoint "./AnnotationTuple.hs" 32 1 diff --git a/testsuite/tests/ghc-api/annotations/stringSource.hs b/testsuite/tests/ghc-api/annotations/stringSource.hs index 21cc867598..9c5d114211 100644 --- a/testsuite/tests/ghc-api/annotations/stringSource.hs +++ b/testsuite/tests/ghc-api/annotations/stringSource.hs @@ -30,7 +30,7 @@ main = do testOneFile libdir fileName testOneFile libdir fileName = do - ((anns,cs),p) <- runGhc (Just libdir) $ do + p <- runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags let mn =mkModuleName fileName @@ -40,7 +40,7 @@ testOneFile libdir fileName = do load LoadAllTargets modSum <- getModSummary mn p <- parseModule modSum - return (pm_annotations p,p) + return p let tupArgs = gq (pm_parsed_source p) diff --git a/testsuite/tests/ghc-api/annotations/t11430.hs b/testsuite/tests/ghc-api/annotations/t11430.hs index 9de2100a01..81c070c01c 100644 --- a/testsuite/tests/ghc-api/annotations/t11430.hs +++ b/testsuite/tests/ghc-api/annotations/t11430.hs @@ -30,7 +30,7 @@ main = do testOneFile libdir fileName testOneFile libdir fileName = do - ((anns,cs),p) <- runGhc (Just libdir) $ do + p <- runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags let mn =mkModuleName fileName @@ -40,7 +40,7 @@ testOneFile libdir fileName = do load LoadAllTargets modSum <- getModSummary mn p <- parseModule modSum - return (pm_annotations p,p) + return p let tupArgs = gq (pm_parsed_source p) |