summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-03-31 13:31:37 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-02 01:50:36 -0400
commit30a63e79c65b023497af4fe2347149382c71829d (patch)
tree581691ff95abe35df3bf26859eebb59dfe5db937 /compiler
parent4980200255dabf59ae537f10c55d19ef1a00bbdd (diff)
downloadhaskell-30a63e79c65b023497af4fe2347149382c71829d.tar.gz
Fix two ASSERT buglets in reifyDataCon
Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087).
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcSplice.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
index 40e16d1305..df32401bc7 100644
--- a/compiler/typecheck/TcSplice.hs
+++ b/compiler/typecheck/TcSplice.hs
@@ -1769,7 +1769,7 @@ reifyDataCon isGadtDataCon tys dc
-- constructors can be declared infix.
-- See Note [Infix GADT constructors] in TcTyClsDecls.
| dataConIsInfix dc && not isGadtDataCon ->
- ASSERT( arg_tys `lengthIs` 2 ) do
+ ASSERT( r_arg_tys `lengthIs` 2 ) do
{ let [r_a1, r_a2] = r_arg_tys
[s1, s2] = dcdBangs
; return $ TH.InfixC (s1,r_a1) name (s2,r_a2) }
@@ -1788,7 +1788,7 @@ reifyDataCon isGadtDataCon tys dc
{ cxt <- reifyCxt theta'
; ex_tvs'' <- reifyTyVars ex_tvs'
; return (TH.ForallC ex_tvs'' cxt main_con) }
- ; ASSERT( arg_tys `equalLength` dcdBangs )
+ ; ASSERT( r_arg_tys `equalLength` dcdBangs )
ret_con }
{-