Skip to content

Fix: treat top-level QuasiQuote splices as using QuasiQuotes (fixes #1650)#1684

Open
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:fix/quasiquotes-decl-splice
Open

Fix: treat top-level QuasiQuote splices as using QuasiQuotes (fixes #1650)#1684
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:fix/quasiquotes-decl-splice

Conversation

@mgajda
Copy link
Copy Markdown

@mgajda mgajda commented Apr 19, 2026

Fixes #1650.

Top-level quasi-quote declarations like

{-# LANGUAGE QuasiQuotes #-}
[qq| ... |]

produce an HsSpliceD node, not an HsExpr. The used QuasiQuotes predicate in src/Hint/Extensions.hs only checked HsExpr-level (isQuasiQuoteExpr) and type-level (isTyQuasiQuote), so the pragma was flagged as "Unused LANGUAGE pragma" even though removing it breaks the parse.

Extend the check with isQuasiQuoteSplice, already exported from ghc-lib-parser-ex and already used in the TemplateHaskell predicate for the complementary purpose.

Test added to <TEST> block in src/Hint/Extensions.hs. Self-test: 965 tests, all pass.

…dmitchell#1650)

Top-level quasi-quote declarations like

    {-# LANGUAGE QuasiQuotes #-}
    [qq| ... |]

produce an HsSpliceD node, not an HsExpr. The existing QuasiQuotes usage
predicate only checked HsExpr-level (isQuasiQuoteExpr) and type-level
(isTyQuasiQuote), so the pragma was flagged as "Unused LANGUAGE pragma"
even though removing it breaks the parse.

Extend the check with isQuasiQuoteSplice (already exported from
ghc-lib-parser-ex and used in the TemplateHaskell predicate for the
complementary purpose).

Test: {-# LANGUAGE QuasiQuotes #-} [qq| ... |] is now accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive "Unused LANGUAGE pragma"

1 participant