Opened 2 years ago

Closed 2 years ago

#14051 closed bug (fixed)

Unboxed sums-related panic: getUnboxedSumName 513

Reported by: RyanGlScott Owned by: bgamari
Priority: highest Milestone: 8.2.2
Component: Compiler Version: 8.2.1-rc2
Keywords: UnboxedSums Cc: dfeuer, bgamari
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: unboxedsums/T14051
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3805
Wiki Page:


Originally reported here. You'll need these two files:

-- Testing.hs
{-# LANGUAGE UnboxedSums #-}

module Testing where

func :: s -> (# Bool | Bool #)
func _ = (# True | #)
-- Bug.hs
{-# LANGUAGE UnboxedSums #-}

module Main where

import Testing

main :: IO ()
main = print $ func 1

And you must compile them like so (the -c and -O2 flags are important):

$ ghc -O2 -c Testing.hs 
$ ghc -O2 -c Bug.hs
ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.1 for x86_64-unknown-linux):
  Call stack:
      CallStack (from HasCallStack):
        prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
        callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
        pprPanic, called at compiler/prelude/KnownUniques.hs:104:5 in ghc:KnownUniques

Reproducible with GHC 8.2.1 and HEAD.

Change History (7)

comment:1 Changed 2 years ago by dfeuer

Cc: dfeuer added
Component: CompilerCompiler (Type checker)
Type of failure: None/UnknownGHC accepts invalid program

If I understand things correctly, the type checker should refuse to print a (# Bool | Bool #).

comment:2 Changed 2 years ago by RyanGlScott

Cc: bgamari added
Component: Compiler (Type checker)Compiler
Type of failure: GHC accepts invalid programNone/Unknown

The fact that the code in Main doesn't typecheck is unimportant, since you can also trigger the panic with this code that does typecheck:

-- Bug.hs
{-# LANGUAGE UnboxedSums #-}

module Main where

import Testing

main :: IO ()
main = print $ case func () of
  (# True | #) -> 123
  _ -> 321

cc'ing Ben, who wrote the getUnboxedSumName function in 34d933d6a821edf5abfcbee76d9325362fc28a13.

comment:3 Changed 2 years ago by bgamari

Milestone: 8.2.2
Owner: set to bgamari
Priority: normalhighest

Thanks for the report! I'm on it.

comment:4 Changed 2 years ago by bgamari

Differential Rev(s): Phab:D3805
Status: newpatch

comment:5 Changed 2 years ago by Ben Gamari <ben@…>

In 5a7af95a/ghc:

KnownUniques: Handle DataCon wrapper names

For some reason these weren't handled. I seem to remember thinking I had
a reason for omitting them when writing the original patch, but I don't
recall what that reason was at this point and clearly workers do show up
in interface files.

Test Plan: Validate against T14051

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #14051

Differential Revision:

comment:6 Changed 2 years ago by RyanGlScott

Status: patchmerge
Test Case: unboxedsums/T14051

comment:7 Changed 2 years ago by bgamari

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