Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8368 closed bug (fixed)

Panic in rejigConRes

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_fail/{T8368,T8368a}
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When I compile the following erroneous code

{-# LANGUAGE DataKinds, TypeFamilies, GADTs #-}

import GHC.TypeLits

data Foo = Bar

data instance Sing (n :: Foo) where
  SBar :: Sing Foo

I get

*** Exception: compiler/typecheck/TcTyClsDecls.lhs:1266:5-62: Irrefutable pattern failed for pattern Data.Maybe.Just subst

I think this is my fault. I will fix.

Attachments (2)

0001-Fix-Trac-8368.patch (7.6 KB) - added by goldfire 5 years ago.
0001-New-tests-for-8368.patch (2.9 KB) - added by goldfire 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by goldfire

Status: newpatch

I have fixed this, but I am unable to validate, as per this email. If someone wants to validate and push, I'd be grateful. Or, suggest a way I can validate. :)

Changed 5 years ago by goldfire

Attachment: 0001-Fix-Trac-8368.patch added

Changed 5 years ago by goldfire

comment:2 Changed 5 years ago by monoidal

@goldfire: It passes validate, except for some perf tests which failed previously. Do you want this trace? It is visible during normal build of ghc.

pprTrace "RAE1" (vcat [ppr tmpl_tvs, ppr res_tmpl, ppr dc_tvs, ppr res_ty]) $ 

comment:3 Changed 5 years ago by goldfire

Yikes, no! Thanks for catching that -- searching for my initials is one of my internal steps during validation, which I obviously skipped. I just checked, and that should be the only one to remove.


comment:4 Changed 5 years ago by Krzysztof Gogolewski <krz.gogolewski@…>

In 0c7d2d7507b9e4dca24c159c0bfcce9de7b233c4/ghc:

Fix Trac #8368.

Two different fixes were necessary here. First, we need to fail eagerly
in kcConDecl, to prevent the return-type error in tcConDecl from firing
twice. (This wasn't caught earlier because of the eager fail in the
datatype kind-checking code -- which isn't used for data instances!)
We also must check again in tcDataFamInstDecl, because it's possible for
a data instance return type to have the right head but the wrong body
(i.e., doesn't conform to the data instance type patterns). This check
is only possible *after* desugaring from HsType to Type, so it can't be
done in tcConRes with the first check.

This is documented in a comment at check_valid_data_con, a local
function within tcDataFamInstDecl.

comment:5 Changed 5 years ago by Krzysztof Gogolewski <krz.gogolewski@…>

comment:6 Changed 5 years ago by monoidal

Resolution: fixed
Status: patchclosed


comment:7 Changed 5 years ago by goldfire

Test Case: indexed-types/should_fail/{T8368,T8368a}

Thanks, monoidal, for doing the last leg of the fix.

Note: See TracTickets for help on using tickets.