summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-12-26 19:47:04 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-25 05:21:40 -0500
commitc3fde723633d1788e4ded8c6f59eb7cef1ae95fd (patch)
tree60f6c00540541449b7aada6765048de49af9f371 /testsuite/tests
parent86966d48954db4a8bd40046af259ed60aed535eb (diff)
downloadhaskell-c3fde723633d1788e4ded8c6f59eb7cef1ae95fd.tar.gz
Handle local fixity declarations in DsMeta properly
`DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the effect of causing local fixity declarations to be dropped when quoted in Template Haskell. But there is no good reason for this state of affairs, as the code in `DsMeta.repFixD` (which handles top-level fixity declarations) handles local fixity declarations just fine. This patch factors out the necessary parts of `repFixD` so that they can be used in `rep_sig` as well. There was one minor complication: the fixity signatures for class methods in each `HsGroup` were stored both in `FixSig`s _and_ the list of `LFixitySig`s for top-level fixity signatures, so I needed to take action to prevent fixity signatures for class methods being converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting these fixity signatures in two places and added `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls` to explain the new design. Fixes #17608. Bumps the Haddock submodule.
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/th/T17608.hs20
-rw-r--r--testsuite/tests/th/T17608.stderr36
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/tests/th/T17608.hs b/testsuite/tests/th/T17608.hs
new file mode 100644
index 0000000000..9d41f658d5
--- /dev/null
+++ b/testsuite/tests/th/T17608.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T17608 where
+
+$([d| infixl 4 `f`
+ f :: Bool
+ f = let infixl 4 `h`
+ h :: () -> Bool -> Bool
+ h _ _ = True in
+ h () (g () ())
+ where
+ infixl 4 `g`
+ g :: () -> () -> Bool
+ g _ _ = True
+
+ infixl 4 `n`
+ class C a where
+ infixl 4 `m`
+ m :: a -> a -> a
+ n :: a -> a -> a
+ |])
diff --git a/testsuite/tests/th/T17608.stderr b/testsuite/tests/th/T17608.stderr
new file mode 100644
index 0000000000..1073c5030b
--- /dev/null
+++ b/testsuite/tests/th/T17608.stderr
@@ -0,0 +1,36 @@
+T17608.hs:(4,2)-(20,7): Splicing declarations
+ [d| infixl 4 `n`
+ infixl 4 `f`
+
+ f :: Bool
+ f = let
+ infixl 4 `h`
+ h :: () -> Bool -> Bool
+ h _ _ = True
+ in h () (g () ())
+ where
+ infixl 4 `g`
+ g :: () -> () -> Bool
+ g _ _ = True
+
+ class C a where
+ infixl 4 `m`
+ m :: a -> a -> a
+ n :: a -> a -> a |]
+ ======>
+ infixl 4 `f`
+ f :: Bool
+ f = let
+ infixl 4 `h`
+ h :: () -> Bool -> Bool
+ h _ _ = True
+ in (h ()) ((g ()) ())
+ where
+ infixl 4 `g`
+ g :: () -> () -> Bool
+ g _ _ = True
+ infixl 4 `n`
+ class C a where
+ infixl 4 `m`
+ m :: a -> a -> a
+ n :: a -> a -> a
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index bcaf5fbd1b..1e0eb38218 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -495,5 +495,6 @@ test('T17379a', normal, compile_fail, [''])
test('T17379b', normal, compile_fail, [''])
test('T17461', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T17511', normal, compile, [''])
+test('T17608', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('TH_PprStar', normal, compile, ['-v0 -dsuppress-uniques'])
test('TH_StringLift', normal, compile, [''])