Skip to content

PatternSynonyms regression in GHC HEAD (expectJust mkOneConFull)

This code works in GHC 8.2:

{-# LANGUAGE PatternSynonyms #-}
module Bug where

data Foo a = Foo1 a | Foo2 a

pattern MyFoo2 :: Int -> Foo Int
pattern MyFoo2 i = Foo2 i

{-# COMPLETE Foo1, MyFoo2 #-}

f :: Foo a -> a
f (Foo1 x) = x

But it throws a compile-time exception on GHC HEAD:

$ ghc3/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.3.20170815 for x86_64-unknown-linux):
        expectJust mkOneConFull
CallStack (from HasCallStack):
  error, called at compiler/utils/Maybes.hs:53:27 in ghc:Maybes
  expectJust, called at compiler/deSugar/Check.hs:1128:37 in ghc:Check
Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority highest
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information