Opened 4 years ago

Closed 4 years ago

Last modified 4 weeks ago

#11336 closed bug (fixed)

GHC craches on this combination of ViewPatterns and PatternSynonyms

Reported by: baramoglo Owned by:
Priority: normal Milestone: 8.0.1
Component: Compiler Version: 7.10.2
Keywords: PatternSynonyms Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The attached file crashes:

$ ghc Bug.hs 
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.10.2 for x86_64-unknown-linux):
	Prelude.last: empty list

I wasn't able to shrink the example further despite many attepts.

Tested on GHC 7.8.3 and 7.10.2.

Attachments (1)

Bug.hs (653 bytes) - added by baramoglo 4 years ago.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by baramoglo

Attachment: Bug.hs added

comment:1 Changed 4 years ago by baramoglo

Forgot to say that I'm able to work around the problem by changing the last line to

fun (Sym (prj -> Just B) :$ _) = undefined

So this is not a blocker for me.

comment:2 Changed 4 years ago by mpickering

Keywords: PatternSynonyms added

comment:3 Changed 4 years ago by simonpj

Happily this works in HEAD, and hence (I expect -- someone pls check) GHC 8.0.

I don't think we'll fix 7.10. Pattern synonyms have had a major re-work since then.

Simon

comment:4 Changed 4 years ago by Simon Peyton Jones <simonpj@…>

In 256c2cf/ghc:

Test Trac #11336

comment:5 Changed 4 years ago by bgamari

Milestone: 8.0.1
Resolution: fixed
Status: newclosed

comment:6 Changed 4 weeks ago by Marge Bot <ben+marge-bot@…>

In a308b43/ghc:

Fix #17112

The `mkOneConFull` function of the pattern match checker used to try to
guess the type arguments of the data type's type constructor by looking
at the ambient type of the match. This doesn't work well for Pattern
Synonyms, where the result type isn't even necessarily a TyCon
application, and it shows in #11336 and #17112.

Also the effort seems futile; why try to try hard when the type checker
has already done the hard lifting? After this patch, we instead supply
the type constructors arguments as an argument to the function and
lean on the type-annotated AST.
Note: See TracTickets for help on using tickets.