Opened 3 years ago

Closed 3 years ago

Last modified 2 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-7.10.0.20141222 test.hs 
[1 of 1] Compiling Main             ( test.hs, test.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.10.0.20141222 for x86_64-apple-darwin):
	find_tycon
  Test
  [Test defined at test.hs:6:9,
   Test parent:Test defined at test.hs:4:13]

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

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 3 years ago by gamegoblin

Version: 7.8.47.10.1-rc1

comment:2 Changed 3 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 3 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-7.10.0.20150119 -c test.hs 

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

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 3 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 3 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-7.10.0.20141222-src.tar.xz --wildcards '*/GIT_COMMIT_ID'
a8c556dfca3eca5277615cc2bf9d6c8f1f143c9a

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

comment:7 Changed 3 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.

Simon

comment:8 Changed 2 years ago by adamgundry

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

Note: See TracTickets for help on using tickets.