Skip to content

Commit f334cbd

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 53664f9 commit f334cbd

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
@@ -3610,7 +3610,7 @@ thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36103610
bdoc <- createDoc bPath "haskell" bSource
36113611
cdoc <- createDoc cPath "haskell" cSource
36123612

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

36153615
-- Change th from () to Bool
36163616
let aSource' = T.unlines $ init (T.lines aSource) ++ ["th_a = [d| a = False|]"]
@@ -3622,7 +3622,7 @@ thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36223622
expectDiagnostics
36233623
[("THC.hs", [(DsError, (4, 4), "Couldn't match expected type '()' with actual type 'Bool'")])
36243624
,("THC.hs", [(DsWarning, (6,0), "Top-level binding")])
3625-
,("THB.hs", [(DsWarning, (4,0), "Top-level binding")])
3625+
,("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level bindin")])
36263626
]
36273627

36283628
closeDoc adoc
@@ -3645,7 +3645,7 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36453645
adoc <- createDoc aPath "haskell" aSource
36463646
bdoc <- createDoc bPath "haskell" bSource
36473647

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

36503650
let aSource' = T.unlines $ init (init (T.lines aSource)) ++ ["th :: DecsQ", "th = [d| a = False|]"]
36513651
changeDoc adoc [TextDocumentContentChangeEvent Nothing Nothing aSource']
@@ -3654,7 +3654,7 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
36543654
let bSource' = T.unlines $ init (T.lines bSource) ++ ["$th"]
36553655
changeDoc bdoc [TextDocumentContentChangeEvent Nothing Nothing bSource']
36563656

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

36593659
closeDoc adoc
36603660
closeDoc bdoc
@@ -4648,7 +4648,7 @@ ifaceTHTest = testCase "iface-th-test" $ runWithExtraFiles "TH" $ \dir -> do
46484648
changeDoc cdoc [TextDocumentContentChangeEvent Nothing Nothing cSource]
46494649
expectDiagnostics
46504650
[("THC.hs", [(DsError, (4, 4), "Couldn't match expected type '()' with actual type 'Bool'")])
4651-
,("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]
4651+
,("THB.hs", [(DsWarning, (4,thDollarIdx), "Top-level binding")])]
46524652
closeDoc cdoc
46534653

46544654
ifaceErrorTest :: TestTree
@@ -5429,3 +5429,11 @@ listOfChar = "String"
54295429
#else
54305430
listOfChar = "[Char]"
54315431
#endif
5432+
5433+
-- | Ghc 9 doesn't include the $-sign in TH warnings like earlier versions did
5434+
thDollarIdx :: Int
5435+
#if MIN_GHC_API_VERSION(9,0,1)
5436+
thDollarIdx = 1
5437+
#else
5438+
thDollarIdx = 0
5439+
#endif

0 commit comments

Comments
 (0)