#15289 closed bug (fixed)

isUnliftedType GHC panic on pattern with True :: Maybe

Reported by: Remi Owned by:
Priority: low Milestone: 8.6.1
Component: Compiler (Type checker) Version: 8.4.3
Keywords: PatternSynonyms Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Oops where

pattern What = True :: Maybe

Fails on 8.4.3 with:

ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.3 for x86_64-unknown-linux):
	isUnliftedType
  (Maybe |> {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

I'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a show-stopper for me.

Change History (9)

comment:1 Changed 15 months ago by Remi

Architecture: aarch64Unknown/Multiple

comment:2 Changed 15 months ago by RyanGlScott

Keywords: PatternSynonyms added

This also panics on GHC HEAD:

$ /opt/ghc/head/bin/ghc Bug2.hs
[1 of 1] Compiling Oops             ( Bug2.hs, Bug2.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.5.20180616 for x86_64-unknown-linux):
        isUnliftedType
  (Maybe |> {co_aWy}) :: TYPE t_aWE[tau:0]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1164:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:1934:10 in ghc:Type

This appears to be a regression from GHC 8.2.2, in which the same program simply gives an error message:

$ /opt/ghc/8.2.2/bin/ghc Bug2.hs
[1 of 1] Compiling Oops             ( Bug2.hs, Bug2.o )

Bug2.hs:5:16: error:
    • Couldn't match expected type ‘Maybe’ with actual type ‘Bool’
    • In the pattern: True
      In the pattern: True :: Maybe
      In the declaration for pattern synonym ‘What’
  |
5 | pattern What = True :: Maybe
  |                ^^^^

Bug2.hs:5:16: error:
    • Couldn't match expected type ‘Maybe’ with actual type ‘Bool’
    • In the expression: True
      In an equation for ‘What’: What = True
  |
5 | pattern What = True :: Maybe
  |                ^^^^^^^^^^^^^

Bug2.hs:5:24: error:
    • Expecting one more argument to ‘Maybe’
      Expected a type, but ‘Maybe’ has kind ‘* -> *’
    • In the type ‘Maybe’
      In a pattern type signature: Maybe
      In the pattern: True :: Maybe
  |
5 | pattern What = True :: Maybe
  |                        ^^^^^

comment:3 Changed 15 months ago by RyanGlScott

Cc: simonpj added

This was introduced in commit 594879dcb2fd5421d5f6ce5341442de32a4aac0a (Fix floating of equalities).

comment:4 Changed 15 months ago by Ben Gamari <ben@…>

In 7b8dcd90/ghc:

testsuite: Add broken test for #15289

The stderr output is merely a guess at what we should expect, but currently this
is certainly broken.

comment:5 Changed 15 months ago by Simon Peyton Jones <simonpj@…>

In 2896082e/ghc:

Fix error recovery for pattern synonyms

As Trac #15289 showed, we were carrying on after a type error
in a pattern synonym, and then crashing.  This patch improves
error handling for pattern synonyms.

I also moved a bit of code from TcBinds into TcPatSyn, which
helpfully narrows the API.

comment:6 Changed 15 months ago by RyanGlScott

Simon, is this a merge candidate for 8.6.1?

comment:7 Changed 15 months ago by bgamari

Status: newmerge

It seems like a simple enough patch and this is clearly a bug so I'm happy to merge.

comment:8 Changed 15 months ago by simonpj

Yes, probably worth merging

comment:9 Changed 14 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.