Skip to content

Commit f258edd

Browse files
committed
tests: Ghc9 shows TH-errors after the dollar sign
Instead of including it like older versions did $(foo) ~~~~ some TH error/warning
1 parent f97b557 commit f258edd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ghcide/test/exe/Main.hs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@ thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36603660
bdoc <- createDoc bPath "haskell" bSource
36613661
cdoc <- createDoc cPath "haskell" cSource
36623662

3663-
expectDiagnostics [("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]
3663+
expectDiagnostics [("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level binding")])]
36643664

36653665
-- Change th from () to Bool
36663666
let aSource' = T.unlines $ init (T.lines aSource) ++ ["th_a = [d| a = False|]"]
@@ -3672,7 +3672,7 @@ thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36723672
expectDiagnostics
36733673
[("THC.hs", [(DsError, (4, 4), "Couldn't match expected type '()' with actual type 'Bool'")])
36743674
,("THC.hs", [(DsWarning, (6,0), "Top-level binding")])
3675-
,("THB.hs", [(DsWarning, (4,0), "Top-level binding")])
3675+
,("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level bindin")])
36763676
]
36773677

36783678
closeDoc adoc
@@ -3695,7 +3695,7 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36953695
adoc <- createDoc aPath "haskell" aSource
36963696
bdoc <- createDoc bPath "haskell" bSource
36973697

3698-
expectDiagnostics [("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]
3698+
expectDiagnostics [("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level binding")])]
36993699

37003700
let aSource' = T.unlines $ init (init (T.lines aSource)) ++ ["th :: DecsQ", "th = [d| a = False|]"]
37013701
changeDoc adoc [TextDocumentContentChangeEvent Nothing Nothing aSource']
@@ -3704,7 +3704,7 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
37043704
let bSource' = T.unlines $ init (T.lines bSource) ++ ["$th"]
37053705
changeDoc bdoc [TextDocumentContentChangeEvent Nothing Nothing bSource']
37063706

3707-
expectDiagnostics [("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]
3707+
expectDiagnostics [("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level binding")])]
37083708

37093709
closeDoc adoc
37103710
closeDoc bdoc
@@ -4698,7 +4698,7 @@ ifaceTHTest = testCase "iface-th-test" $ runWithExtraFiles "TH" $ \dir -> do
46984698
changeDoc cdoc [TextDocumentContentChangeEvent Nothing Nothing cSource]
46994699
expectDiagnostics
47004700
[("THC.hs", [(DsError, (4, 4), "Couldn't match expected type '()' with actual type 'Bool'")])
4701-
,("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]
4701+
,("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level binding")])]
47024702
closeDoc cdoc
47034703

47044704
ifaceErrorTest :: TestTree
@@ -5515,3 +5515,11 @@ listOfChar = "String"
55155515
#else
55165516
listOfChar = "[Char]"
55175517
#endif
5518+
5519+
-- | Ghc 9 doesn't include the $-sign in TH warnings like earlier versions did
5520+
thDollarIdx :: Int
5521+
#if MIN_GHC_API_VERSION(9,0,1)
5522+
thDollarIdx = 1
5523+
#else
5524+
thDollarIdx = 0
5525+
#endif

0 commit comments

Comments
 (0)