Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 639456a8 by Evgeny Malyshev at 2026-09-04T08:09:25-04:00 HsPat: Add spacing to unary tuple patterns Use hsep when printing unary boxed TuplePat applications so that the MkSolo constructor is separated from its argument. The old hcat rendered wildcard and parenthesized arguments as MkSolo_ and MkSolo(). Add T27034 to exercise the HsPat splice-dump path with wildcard and variable arguments, and update existing affected golden output. Fixes #27034 Assisted-By: OpenAI Codex - - - - - 7 changed files: - compiler/GHC/Hs/Pat.hs - testsuite/tests/th/T17380.stderr - testsuite/tests/th/T18612.stderr - + testsuite/tests/th/T27034.hs - + testsuite/tests/th/T27034.stderr - testsuite/tests/th/T8761.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -443,7 +443,7 @@ pprPat (TuplePat _ pats bx) -- `MkSolo x`, not `(x)` | [pat] <- pats , Boxed <- bx - = hcat [text (mkTupleStr Boxed dataName 1), pprParendLPat appPrec pat] + = hsep [text (mkTupleStr Boxed dataName 1), pprParendLPat appPrec pat] | otherwise = tupleParens (boxityTupleSort bx) (pprWithCommas ppr pats) pprPat (SumPat _ pat alt arity) = sumParens (pprAlternative ppr pat alt arity) ===================================== testsuite/tests/th/T17380.stderr ===================================== @@ -19,8 +19,8 @@ T17380.hs:15:6: error: [GHC-83865] T17380.hs:18:7: error: [GHC-83865] • Couldn't match expected type: Maybe String with actual type: Solo (Maybe String) - • In the pattern: MkSolo(Just "wat") - In an equation for ‘quux’: quux (MkSolo(Just "wat")) = Just "frerf" + • In the pattern: MkSolo (Just "wat") + In an equation for ‘quux’: quux (MkSolo (Just "wat")) = Just "frerf" T17380.hs:21:8: error: [GHC-83865] • Couldn't match type: Maybe String ===================================== testsuite/tests/th/T18612.stderr ===================================== @@ -8,6 +8,6 @@ T18612.hs:(10,7)-(11,75): Splicing type ======> Identity (Solo ()) -> Identity (Solo ()) T18612.hs:12:4-36: Splicing pattern - conP 'Identity [tupP [tupP []]] ======> Identity (MkSolo()) + conP 'Identity [tupP [tupP []]] ======> Identity (MkSolo ()) T18612.hs:12:41-78: Splicing expression conE 'Identity `appE` tupE [tupE []] ======> Identity (MkSolo ()) ===================================== testsuite/tests/th/T27034.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module T27034 where + +import Language.Haskell.TH + +f $(tupP [wildP]) = () +g $(tupP [varP (mkName "x")]) = x ===================================== testsuite/tests/th/T27034.stderr ===================================== @@ -0,0 +1,4 @@ +T27034.hs:6:4-17: Splicing pattern + tupP [wildP] ======> MkSolo _ +T27034.hs:7:4-29: Splicing pattern + tupP [varP (mkName "x")] ======> MkSolo x ===================================== testsuite/tests/th/T8761.stderr ===================================== @@ -28,7 +28,7 @@ T8761.hs:(16,1)-(39,13): Splicing declarations return pats ======> pattern Q1 x1 x2 x3 <- ((x1, x2), [x3], _, _) - pattern x1 `Q2` x2 = MkSolo(x1, x2) + pattern x1 `Q2` x2 = MkSolo (x1, x2) pattern Q3{qx3, qy3, qz3} <- ((qx3, qy3), [qz3]) where Q3 qx3 qy3 qz3 = ((qx3, qy3), [qz3]) T8761.hs:(42,1)-(46,29): Splicing declarations ===================================== testsuite/tests/th/all.T ===================================== @@ -655,6 +655,7 @@ test('T26099', normal, compile_fail, ['']) test('T8306_th', only_ways(['ghci']), ghci_script, ['T8306_th.script']) test('T26862_th', only_ways(['ghci']), ghci_script, ['T26862_th.script']) test('T27022', normal, compile_and_run, ['']) +test('T27034', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T20902', normal, compile, ['']) test('TH_cvt_DefaultDataInstDecl', normal, compile_fail, ['-v0']) test('TH_cvt_IllegalDeclaration', normal, compile_fail, ['-v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/639456a83d19137677e9a2dd59ef9b43... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/639456a83d19137677e9a2dd59ef9b43... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help