Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#9975 closed bug (fixed)

RecordWildcards and PatternSynonyms cause impossible bug

Reported by: gamegoblin Owned by:
Priority: normal Milestone: 7.10.1
Component: Compiler Version: 7.10.1-rc1
Keywords: RecordWildcards PatternSynonyms Cc: cactus
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case: patsyn/should_compile/T9975a,b
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by hvr)

When using RecordWildcards with PatternSynonyms, I have found a way to cause this bug:

$ /usr/local/bin/ghc- test.hs 
[1 of 1] Compiling Main             ( test.hs, test.o )
ghc: panic! (the 'impossible' happened)
  (GHC version for x86_64-apple-darwin):
  [Test defined at test.hs:6:9,
   Test parent:Test defined at test.hs:4:13]

Please report this as a GHC bug:

Here is the full code that causes it:

{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE PatternSynonyms #-}
data Test = Test { x :: Int }
pattern Test wat = Test { x = wat }

If you remove RecordWildCards, the bug does not happen.

Change History (8)

comment:1 Changed 5 years ago by gamegoblin


comment:2 Changed 5 years ago by gamegoblin

Description: modified (diff)
Keywords: RecordWildcards added; RecordWildCards removed
Summary: RecordWildCards and PatternSynonyms cause impossible bugRecordWildcards and PatternSynonyms cause impossible bug

comment:3 Changed 5 years ago by hvr

Cc: cactus added
Description: modified (diff)
Milestone: 7.10.1
Operating System: MacOS XUnknown/Multiple

Maybe this was fixed already, as I can't reproduce it anymore with a current ghc-7.10 snapshot:

$ ghc- -c test.hs 

    Multiple declarations of ‘Test’
    Declared at: test.hs:3:13

It may be worth bisecting to find out which commit fixed it, unless cactus happens to know already which commit fixed it...

comment:4 Changed 5 years ago by cactus

Is 7.10.1-rc1 properly tagged in Git? I can't seem to find the exact commit corresponding to it.

comment:5 Changed 5 years ago by hvr

cactus, it's not tagged (RCs weren't tagged in the past either), but luckily ghc --info nowadays spits out the commit id (and it's contained in the src tarball), so it's:

$ tar xOf ghc- --wildcards '*/GIT_COMMIT_ID'

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

comment:7 Changed 5 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: patsyn/should_compile/T9975a,b

I'm not sure what fixed it, but I'm content to let sleeping dogs lie. I've added a regression test though.


comment:8 Changed 4 years ago by adamgundry

See also #11283, which is essentially the same bug.

Note: See TracTickets for help on using tickets.