summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api/annotations
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2019-02-03 10:27:42 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-08 11:00:22 -0500
commitc1cf2693d6efddeeeb813cd8995a1be136800d17 (patch)
tree24130e1f3f9b697e7cb622ebf780f36f2271c5f0 /testsuite/tests/ghc-api/annotations
parent5e9888bd9c22a1315a703f638591b50e657317c4 (diff)
downloadhaskell-c1cf2693d6efddeeeb813cd8995a1be136800d17.tar.gz
Lexer: Alternate Layout Rule injects actual not virtual braces
When the alternate layout rule is activated via a pragma, it injects tokens for { and } to make sure that the source is parsed properly. But it injects ITocurly and ITccurly, rather than their virtual counterparts ITvocurly and ITvccurly. This causes problems for ghc-exactprint, which tries to print these. Likewise, any injected ITsemi should have a zero-width SrcSpan. Test case (the existing T13087.hs) {-# LANGUAGE AlternativeLayoutRule #-} {-# LANGUAGE LambdaCase #-} isOne :: Int -> Bool isOne = \case 1 -> True _ -> False main = return () Closes #16279
Diffstat (limited to 'testsuite/tests/ghc-api/annotations')
-rw-r--r--testsuite/tests/ghc-api/annotations/Makefile4
-rw-r--r--testsuite/tests/ghc-api/annotations/T16279.stdout30
-rw-r--r--testsuite/tests/ghc-api/annotations/Test16279.hs10
-rw-r--r--testsuite/tests/ghc-api/annotations/all.T2
4 files changed, 46 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-api/annotations/Makefile b/testsuite/tests/ghc-api/annotations/Makefile
index da3be434ff..f293810d20 100644
--- a/testsuite/tests/ghc-api/annotations/Makefile
+++ b/testsuite/tests/ghc-api/annotations/Makefile
@@ -161,3 +161,7 @@ T16236:
.PHONY: StarBinderAnns
StarBinderAnns:
$(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" StarBinderAnns.hs
+
+.PHONY: T16279
+T16279:
+ $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test16279.hs
diff --git a/testsuite/tests/ghc-api/annotations/T16279.stdout b/testsuite/tests/ghc-api/annotations/T16279.stdout
new file mode 100644
index 0000000000..7dac950679
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/T16279.stdout
@@ -0,0 +1,30 @@
+---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
+[
+((Test16279.hs:5:1-20,AnnDcolon), [Test16279.hs:5:7-8]),
+((Test16279.hs:5:1-20,AnnSemi), [Test16279.hs:6:1]),
+((Test16279.hs:5:10-12,AnnRarrow), [Test16279.hs:5:14-15]),
+((Test16279.hs:5:10-20,AnnRarrow), [Test16279.hs:5:14-15]),
+((Test16279.hs:(6,1)-(7,24),AnnEqual), [Test16279.hs:6:7]),
+((Test16279.hs:(6,1)-(7,24),AnnFunId), [Test16279.hs:6:1-5]),
+((Test16279.hs:(6,1)-(7,24),AnnSemi), [Test16279.hs:9:1]),
+((Test16279.hs:(6,9)-(7,24),AnnCase), [Test16279.hs:6:10-13]),
+((Test16279.hs:(6,9)-(7,24),AnnLam), [Test16279.hs:6:9]),
+((Test16279.hs:6:15-23,AnnSemi), [Test16279.hs:7:15]),
+((Test16279.hs:6:17-23,AnnRarrow), [Test16279.hs:6:17-18]),
+((Test16279.hs:7:17-24,AnnRarrow), [Test16279.hs:7:17-18]),
+((Test16279.hs:9:1-16,AnnEqual), [Test16279.hs:9:6]),
+((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
diff --git a/testsuite/tests/ghc-api/annotations/Test16279.hs b/testsuite/tests/ghc-api/annotations/Test16279.hs
new file mode 100644
index 0000000000..7817edadc5
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/Test16279.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE AlternativeLayoutRule #-}
+{-# LANGUAGE LambdaCase #-}
+-- duplicate of T13087.hs
+
+isOne :: Int -> Bool
+isOne = \case 1 -> True
+ _ -> False
+
+main = return ()
+
diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T
index 8635ba1934..1d44ac0816 100644
--- a/testsuite/tests/ghc-api/annotations/all.T
+++ b/testsuite/tests/ghc-api/annotations/all.T
@@ -67,3 +67,5 @@ test('T16236', [extra_files(['Test16236.hs']),
ignore_stderr], makefile_test, ['T16236'])
test('StarBinderAnns', [extra_files(['StarBinderAnns.hs']),
ignore_stderr], makefile_test, ['StarBinderAnns'])
+test('T16279', [extra_files(['Test16279.hs']),
+ ignore_stderr], makefile_test, ['T16279'])