[GHC] #15116: GHC internal error when GADT return type mentions its own constructor name
GHC
ghc-devs at haskell.org
Thu May 3 18:42:22 UTC 2018
#15116: GHC internal error when GADT return type mentions its own constructor name
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler (Type | Version: 8.5
checker) | Keywords: GADTs,
Resolution: | TypeInType
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Ah, I see what is going on. This is due to the following change in
`kcLTyClDecl`:
{{{#!diff
kcLTyClDecl :: LTyClDecl GhcRn -> TcM ()
-- See Note [Kind checking for type and class decls]
kcLTyClDecl (L loc decl)
+ | hsDeclHasCusk decl
+ = traceTc "kcTyClDecl skipped due to cusk" (ppr tc_name)
+ | otherwise
= setSrcSpan loc $
tcAddDeclCtxt decl $
- do { traceTc "kcTyClDecl {" (ppr (tyClDeclLName decl))
+ do { traceTc "kcTyClDecl {" (ppr tc_name)
; kcTyClDecl decl
- ; traceTc "kcTyClDecl done }" (ppr (tyClDeclLName decl)) }
+ ; traceTc "kcTyClDecl done }" (ppr tc_name) }
+ where
+ tc_name = tyClDeclLName decl
}}}
Now, if the declaration has a CUSK, then `kcTyClDecl` is skipped entirely.
As a consequence, subsequent checks for each data constructor
(`kcConDecl`) are also skipped. But `kcConDecl` was what was throwing the
error message for the original program, so skipping it leads to
pandemonium later down the line.
How should we fix this? I can think of at least a couple of possibilities:
1. Never skip `kcTyClDecl` if the declaration has constructors.
2. Do the `kcConDecl` checks separately from `kcTyClDecl`.
Thoughts?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15116#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list