From cdcb4fe20e9f3f65f0f0ad065e3d99fededd2434 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 27 Apr 2026 00:46:21 +0100 Subject: [PATCH 1/4] Enable splice plugin on all GHCs --- .github/workflows/test.yml | 3 +-- docs/support/plugin-support.md | 2 +- haskell-language-server.cabal | 6 +++--- test/testdata/schema/ghc910/default-config.golden.json | 3 +++ .../schema/ghc910/vscode-extension-schema.golden.json | 6 ++++++ test/testdata/schema/ghc912/default-config.golden.json | 3 +++ .../schema/ghc912/vscode-extension-schema.golden.json | 6 ++++++ test/testdata/schema/ghc914/default-config.golden.json | 3 +++ .../schema/ghc914/vscode-extension-schema.golden.json | 6 ++++++ 9 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eec5e0dd6b..8272d6df7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -162,8 +162,7 @@ jobs: name: Test hls-eval-plugin run: cabal test ${CABAL_ARGS} hls-eval-plugin-tests || cabal test ${CABAL_ARGS} hls-eval-plugin-tests - # TODO enable when it supports 9.10 - - if: matrix.test && matrix.ghc != '9.10' && matrix.ghc != '9.12' && matrix.ghc != '9.14' && matrix.ghc != '9.10.2' + - if: matrix.test name: Test hls-splice-plugin run: cabal test ${CABAL_ARGS} hls-splice-plugin-tests || cabal test ${CABAL_ARGS} hls-splice-plugin-tests diff --git a/docs/support/plugin-support.md b/docs/support/plugin-support.md index 225522541f..596c613165 100644 --- a/docs/support/plugin-support.md +++ b/docs/support/plugin-support.md @@ -66,6 +66,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has | `hls-semantic-tokens-plugin` | 2 | | | `hls-stan-plugin` | 3 | 9.12.2, 9.14.1 | | `hls-retrie-plugin` | 3 | 9.10.1, 9.12.2, 9.14.1 | -| `hls-splice-plugin` | 3 | 9.10.1, 9.12.2, 9.14.1 | +| `hls-splice-plugin` | 3 | | [1]: HLint is incompatible with GHC 9.10 series. See the issue [#4674](https://github.com/haskell/haskell-language-server/issues/4674) for discussion and explanation. diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 60d4a5c810..ffe930fc81 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -961,13 +961,13 @@ flag splice manual: True common splice - if flag(splice) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds)) + if flag(splice) build-depends: haskell-language-server:hls-splice-plugin cpp-options: -Dhls_splice library hls-splice-plugin import: defaults, pedantic, warnings - if !(flag(splice) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds))) + if !(flag(splice)) buildable: False exposed-modules: Ide.Plugin.Splice @@ -995,7 +995,7 @@ library hls-splice-plugin test-suite hls-splice-plugin-tests import: defaults, pedantic, test-defaults, warnings - if !(flag(splice) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds))) + if !(flag(splice)) buildable: False type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-splice-plugin/test diff --git a/test/testdata/schema/ghc910/default-config.golden.json b/test/testdata/schema/ghc910/default-config.golden.json index 0c0704b257..f5fc40855f 100644 --- a/test/testdata/schema/ghc910/default-config.golden.json +++ b/test/testdata/schema/ghc910/default-config.golden.json @@ -148,6 +148,9 @@ "signatureHelp": { "globalOn": true }, + "splice": { + "globalOn": true + }, "stan": { "globalOn": false } diff --git a/test/testdata/schema/ghc910/vscode-extension-schema.golden.json b/test/testdata/schema/ghc910/vscode-extension-schema.golden.json index 5753290d92..383c4ee5fe 100644 --- a/test/testdata/schema/ghc910/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc910/vscode-extension-schema.golden.json @@ -1037,6 +1037,12 @@ "scope": "resource", "type": "boolean" }, + "haskell.plugin.splice.globalOn": { + "default": true, + "description": "Enables splice plugin", + "scope": "resource", + "type": "boolean" + }, "haskell.plugin.stan.globalOn": { "default": false, "description": "Enables stan plugin", diff --git a/test/testdata/schema/ghc912/default-config.golden.json b/test/testdata/schema/ghc912/default-config.golden.json index 40c7b5b03a..9f4b9f5ab3 100644 --- a/test/testdata/schema/ghc912/default-config.golden.json +++ b/test/testdata/schema/ghc912/default-config.golden.json @@ -154,6 +154,9 @@ }, "signatureHelp": { "globalOn": true + }, + "splice": { + "globalOn": true } }, "sessionLoading": "singleComponent" diff --git a/test/testdata/schema/ghc912/vscode-extension-schema.golden.json b/test/testdata/schema/ghc912/vscode-extension-schema.golden.json index bfc198aa93..9c3c96aba2 100644 --- a/test/testdata/schema/ghc912/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc912/vscode-extension-schema.golden.json @@ -1054,5 +1054,11 @@ "description": "Enables signatureHelp plugin", "scope": "resource", "type": "boolean" + }, + "haskell.plugin.splice.globalOn": { + "default": true, + "description": "Enables splice plugin", + "scope": "resource", + "type": "boolean" } } diff --git a/test/testdata/schema/ghc914/default-config.golden.json b/test/testdata/schema/ghc914/default-config.golden.json index f94188128b..34fc9d921b 100644 --- a/test/testdata/schema/ghc914/default-config.golden.json +++ b/test/testdata/schema/ghc914/default-config.golden.json @@ -136,6 +136,9 @@ }, "signatureHelp": { "globalOn": true + }, + "splice": { + "globalOn": true } }, "sessionLoading": "singleComponent" diff --git a/test/testdata/schema/ghc914/vscode-extension-schema.golden.json b/test/testdata/schema/ghc914/vscode-extension-schema.golden.json index 1875357dd4..6a8d548967 100644 --- a/test/testdata/schema/ghc914/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc914/vscode-extension-schema.golden.json @@ -1018,5 +1018,11 @@ "description": "Enables signatureHelp plugin", "scope": "resource", "type": "boolean" + }, + "haskell.plugin.splice.globalOn": { + "default": true, + "description": "Enables splice plugin", + "scope": "resource", + "type": "boolean" } } From d60630558a5e5c4c5740e8bcf567b91322692c66 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 27 Apr 2026 08:32:52 +0100 Subject: [PATCH 2/4] Add failing tests for TH declaration splices --- plugins/hls-splice-plugin/test/Main.hs | 8 ++++++++ .../test/testdata/TDeclData.expected.hs | 7 +++++++ plugins/hls-splice-plugin/test/testdata/TDeclData.hs | 9 +++++++++ .../test/testdata/TDeclForeignImport.expected.hs | 5 +++++ .../test/testdata/TDeclForeignImport.hs | 5 +++++ .../test/testdata/TDeclInstance.expected.hs | 7 +++++++ .../hls-splice-plugin/test/testdata/TDeclInstance.hs | 12 ++++++++++++ .../test/testdata/TDeclNewtype.expected.hs | 7 +++++++ .../hls-splice-plugin/test/testdata/TDeclNewtype.hs | 7 +++++++ .../test/testdata/TDeclPatSyn.expected.hs | 6 ++++++ .../hls-splice-plugin/test/testdata/TDeclPatSyn.hs | 6 ++++++ .../test/testdata/TDeclPragma.expected.hs | 7 +++++++ .../hls-splice-plugin/test/testdata/TDeclPragma.hs | 9 +++++++++ 13 files changed, 95 insertions(+) create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclData.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclInstance.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclNewtype.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs create mode 100644 plugins/hls-splice-plugin/test/testdata/TDeclPragma.hs diff --git a/plugins/hls-splice-plugin/test/Main.hs b/plugins/hls-splice-plugin/test/Main.hs index 38cbd4d5da..7a1c36fc6a 100644 --- a/plugins/hls-splice-plugin/test/Main.hs +++ b/plugins/hls-splice-plugin/test/Main.hs @@ -54,6 +54,14 @@ tests = testGroup "splice" , goldenTest "TQQTypeTypeError" Inplace 8 28 , goldenTest "TSimpleDecl" Inplace 8 1 , goldenTest "TQQDecl" Inplace 5 1 + , testGroup "Declaration Splices" + [ goldenTest "TDeclForeignImport" Inplace 5 1 + , goldenTest "TDeclData" Inplace 5 1 + , goldenTest "TDeclNewtype" Inplace 5 1 + , goldenTest "TDeclInstance" Inplace 5 1 + , goldenTest "TDeclPatSyn" Inplace 6 1 + , goldenTest "TDeclPragma" Inplace 5 1 + ] , goldenTestWithEdit "TTypeKindError" ( if ghcVersion >= GHC96 then "96-expected" diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs new file mode 100644 index 0000000000..ca846f4bf2 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclData where +import Language.Haskell.TH + +MyData + = MyConA Int | MyConB String + deriving (Show, Eq) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclData.hs b/plugins/hls-splice-plugin/test/testdata/TDeclData.hs new file mode 100644 index 0000000000..b807681a82 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclData.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclData where +import Language.Haskell.TH + +$(pure <$> dataD (pure []) (mkName "MyData") [] Nothing + [ normalC (mkName "MyConA") [bangType (bang noSourceUnpackedness noSourceStrictness) [t|Int|]] + , normalC (mkName "MyConB") [bangType (bang noSourceUnpackedness noSourceStrictness) [t|String|]] + ] + [derivClause Nothing [conT ''Show, conT ''Eq]]) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs new file mode 100644 index 0000000000..1e3c6d388d --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclForeignImport where +import Language.Haskell.TH + + importccall unsafe "math.h sin" c_sin :: Double -> Double diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.hs b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.hs new file mode 100644 index 0000000000..3cde3b10b4 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclForeignImport where +import Language.Haskell.TH + +$(pure <$> forImpD cCall unsafe "math.h sin" (mkName "c_sin") [t|Double -> Double|]) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs new file mode 100644 index 0000000000..31a8264004 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclInstance where +import Language.Haskell.TH + +Wrapper = MkWrapper Int +Show Wrapper where + show (MkWrapper n) = ("Wrapper:" ++ show n) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclInstance.hs b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.hs new file mode 100644 index 0000000000..28affcd182 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclInstance where +import Language.Haskell.TH + +$(do dataDec <- dataD (pure []) (mkName "Wrapper") [] Nothing + [normalC (mkName "MkWrapper") [bangType (bang noSourceUnpackedness noSourceStrictness) [t|Int|]]] + [] + instDec <- instanceD (pure []) (appT (conT ''Show) (conT (mkName "Wrapper"))) + [ funD (mkName "show") [clause [conP (mkName "MkWrapper") [varP (mkName "n")]] + (normalB [|"Wrapper:" ++ show n|]) []] + ] + pure [dataDec, instDec]) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs new file mode 100644 index 0000000000..701e52ba41 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclNewtype where +import Language.Haskell.TH + +MyNewtype + = MkMyNewtype Int + deriving Show diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.hs b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.hs new file mode 100644 index 0000000000..39cc7cde86 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclNewtype where +import Language.Haskell.TH + +$(pure <$> newtypeD (pure []) (mkName "MyNewtype") [] Nothing + (normalC (mkName "MkMyNewtype") [bangType (bang noSourceUnpackedness noSourceStrictness) [t|Int|]]) + [derivClause Nothing [conT ''Show]]) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs new file mode 100644 index 0000000000..a6b4ef1522 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE PatternSynonyms #-} +module TDeclPatSyn where +import Language.Haskell.TH + +MyPattern <- 42 diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.hs new file mode 100644 index 0000000000..54eb45626c --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE PatternSynonyms #-} +module TDeclPatSyn where +import Language.Haskell.TH + +$(pure <$> patSynD (mkName "MyPattern") (prefixPatSyn []) unidir (litP (integerL 42))) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs new file mode 100644 index 0000000000..589d239014 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclPragma where +import Language.Haskell.TH + +myId :: Int -> Int +myId #-} +myId x = x diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPragma.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.hs new file mode 100644 index 0000000000..a7e62c0ce9 --- /dev/null +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TDeclPragma where +import Language.Haskell.TH + +$(sequence + [ sigD (mkName "myId") [t|Int -> Int|] + , pragInlD (mkName "myId") Inline FunLike AllPhases + , funD (mkName "myId") [clause [varP (mkName "x")] (normalB (varE (mkName "x"))) []] + ]) From f06a17d3bf39ec3f470a1cb937c5835876738496 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 27 Apr 2026 00:50:14 +0100 Subject: [PATCH 3/4] Fix splice plugin on GHC 9.10 by using relative annotations in grafted nodes --- .../src/Development/IDE/GHC/ExactPrint.hs | 25 +++++++++++++------ .../test/testdata/TDeclData.expected.hs | 2 +- .../testdata/TDeclForeignImport.expected.hs | 2 +- .../test/testdata/TDeclInstance.expected.hs | 4 +-- .../test/testdata/TDeclNewtype.expected.hs | 2 +- .../test/testdata/TDeclPatSyn.expected.hs | 2 +- .../test/testdata/TDeclPragma.expected.hs | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs index 666de9a6f2..112dc3a6ca 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/GHC/ExactPrint.hs @@ -301,7 +301,7 @@ graft' :: LocatedAn l ast -> Graft (Either String) a graft' needs_space dst val = Graft $ \dflags a -> do - val' <- annotate dflags needs_space val + val' <- annotate dflags needs_space dst val pure $ everywhere' ( mkT $ @@ -371,7 +371,7 @@ graftExprWithM dst trans = Graft $ \dflags a -> do Just val' -> do val'' <- hoistTransform (either Fail.fail pure) - (annotate @AnnListItem @(HsExpr GhcPs) dflags needs_space (mk_parens val')) + (annotate @AnnListItem @(HsExpr GhcPs) dflags needs_space dst (mk_parens val')) pure val'' Nothing -> pure val l -> pure l @@ -395,7 +395,7 @@ graftWithM dst trans = Graft $ \dflags a -> do Just val' -> do val'' <- hoistTransform (either Fail.fail pure) $ - annotate dflags False $ maybeParensAST val' + annotate dflags False dst $ maybeParensAST val' pure val'' Nothing -> pure val l -> pure l @@ -667,6 +667,7 @@ class , Typeable l , Outputable l , Outputable ast + , ExactPrint (LocatedAn l ast) #if !MIN_VERSION_ghc(9,9,0) , Default l #endif @@ -719,12 +720,17 @@ instance ASTElement NameAnn RdrName where -- | Given an 'LHSExpr', compute its exactprint annotations. -- Note that this function will throw away any existing annotations (and format) annotate :: ASTElement l ast - => DynFlags -> Bool -> LocatedAn l ast -> TransformT (Either String) (LocatedAn l ast) -annotate dflags needs_space ast = do + => DynFlags -> Bool -> SrcSpan -> LocatedAn l ast -> TransformT (Either String) (LocatedAn l ast) +annotate dflags _needs_space _loc ast = do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags ast expr' <- TransformT $ lift $ mapLeft (showSDoc dflags . ppr) $ parseAST dflags uniq rendered - pure $ setPrecedingLines expr' 0 (bool 0 1 needs_space) +#if MIN_VERSION_ghc(9,9,0) + let L l e = makeDeltaAst expr' + pure $ L l{entry = spanAsAnchor _loc} e +#else + pure $ setPrecedingLines expr' 0 (bool 0 1 _needs_space) +#endif -- | Given an 'LHsDecl', compute its exactprint annotations. annotateDecl :: DynFlags -> LHsDecl GhcPs -> TransformT (Either String) (LHsDecl GhcPs) @@ -732,7 +738,12 @@ annotateDecl dflags ast = do uniq <- show <$> uniqueSrcSpanT let rendered = render dflags ast expr' <- TransformT $ lift $ mapLeft (showSDoc dflags . ppr) $ parseDecl dflags uniq rendered - pure $ setPrecedingLines expr' 1 0 +#if MIN_VERSION_ghc(9,9,0) + let expr'' = makeDeltaAst expr' +#else + let expr'' = expr' +#endif + pure $ setPrecedingLines expr'' 1 0 ------------------------------------------------------------------------------ diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs index ca846f4bf2..174baba263 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclData.expected.hs @@ -2,6 +2,6 @@ module TDeclData where import Language.Haskell.TH -MyData +data MyData = MyConA Int | MyConB String deriving (Show, Eq) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs index 1e3c6d388d..ba75b8ba64 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclForeignImport.expected.hs @@ -2,4 +2,4 @@ module TDeclForeignImport where import Language.Haskell.TH - importccall unsafe "math.h sin" c_sin :: Double -> Double +foreign import ccall unsafe "math.h sin" c_sin :: Double -> Double diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs index 31a8264004..0d68dbc2b1 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclInstance.expected.hs @@ -2,6 +2,6 @@ module TDeclInstance where import Language.Haskell.TH -Wrapper = MkWrapper Int -Show Wrapper where +data Wrapper = MkWrapper Int +instance Show Wrapper where show (MkWrapper n) = ("Wrapper:" ++ show n) diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs index 701e52ba41..3f971cc4b1 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclNewtype.expected.hs @@ -2,6 +2,6 @@ module TDeclNewtype where import Language.Haskell.TH -MyNewtype +newtype MyNewtype = MkMyNewtype Int deriving Show diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs index a6b4ef1522..0f867c92a3 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPatSyn.expected.hs @@ -3,4 +3,4 @@ module TDeclPatSyn where import Language.Haskell.TH -MyPattern <- 42 +pattern MyPattern <- 42 diff --git a/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs index 589d239014..e828a5b8ea 100644 --- a/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs +++ b/plugins/hls-splice-plugin/test/testdata/TDeclPragma.expected.hs @@ -3,5 +3,5 @@ module TDeclPragma where import Language.Haskell.TH myId :: Int -> Int -myId #-} +{-# INLINE myId #-} myId x = x From cfc780a13f2109fea14fe354de81a188600009a0 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 27 Apr 2026 13:40:03 +0100 Subject: [PATCH 4/4] Fix splice plugin on GHC 9.14 --- .../hls-splice-plugin/src/Ide/Plugin/Splice.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs index de468e2a87..270a0f76de 100644 --- a/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs +++ b/plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs @@ -60,7 +60,9 @@ import Data.Foldable (Foldable (foldl')) import GHC.Data.Bag (Bag) -#if MIN_VERSION_ghc(9,9,0) +#if MIN_VERSION_ghc(9,13,0) +import GHC.Parser.Annotation (EpAnn (..), EpToken (..)) +#elif MIN_VERSION_ghc(9,9,0) import GHC.Parser.Annotation (EpAnn (..)) #else import GHC.Parser.Annotation (SrcSpanAnn' (..)) @@ -305,10 +307,18 @@ class (Outputable (ast GhcRn), ASTElement l (ast GhcPs)) => HasSplice l ast wher instance HasSplice AnnListItem HsExpr where type SpliceOf HsExpr = HsSpliceCompat matchSplice _ (HsUntypedSplice _ spl) = Just (UntypedSplice spl) +#if MIN_VERSION_ghc(9,13,0) + matchSplice _ (HsTypedSplice _ (HsTypedSpliceExpr _ spl)) = Just (TypedSplice spl) +#else matchSplice _ (HsTypedSplice _ spl) = Just (TypedSplice spl) +#endif matchSplice _ _ = Nothing expandSplice _ (UntypedSplice e) = fmap (first Right) $ rnUntypedSpliceExpr e +#if MIN_VERSION_ghc(9,13,0) + expandSplice _ (TypedSplice e) = fmap (first Right) $ rnTypedSplice (HsTypedSpliceExpr NoEpTok e) +#else expandSplice _ (TypedSplice e) = fmap (first Right) $ rnTypedSplice e +#endif instance HasSplice AnnListItem Pat where type SpliceOf Pat = HsUntypedSplice @@ -408,7 +418,11 @@ toDiagnosticMessage message = message , diagReason = Error.diagnosticReason message +#if MIN_VERSION_ghc(9,13,0) + , diagHints = [] +#else , diagHints = Error.diagnosticHints message +#endif } -- | FIXME: Is thereAny "clever" way to do this exploiting TTG?