Opened 6 years ago

Closed 6 years ago

#8762 closed bug (fixed)

Panic involving unboxed tuples and phantom types

Reported by: josef Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.8.1-rc1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_compile/T8762
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I ran into a bug involving unboxed tuples and the following piece of code is an attempt at isolating the problem:

{-# LANGUAGE UnboxedTuples #-}
module Main where

type Ty a = Int

bug :: Ty a -> (# Ty a, () #)
bug ty = (# ty, () #)

main = do
  let (# a, b #) = bug undefined
  return ()

It seems that the phantom type is necessary to trigger the bug.

The bug is still present in 7.8rc1.

Change History (6)

comment:1 Changed 6 years ago by thoughtpolice


comment:2 Changed 6 years ago by thoughtpolice

Milestone: 7.8.1

comment:3 Changed 6 years ago by goldfire

I just took a look at this and ended up in deeper waters within the type-checker than where I feel comfortable. But I did discover that the bug persists with

{-# LANGUAGE UnboxedTuples #-}
module Bug where

data Ty a = Int

bug :: () -> (# Ty a, () #)
bug _ = (# Int, () #)

main :: IO ()
main = do
  let (# a, b #) = bug ()
  return ()

Note that there is no undefined, and the previous type synonym Ty has now become a datatype.

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

In 47f473b0f7ddf21b2cde825166d092cb6e72329d/ghc:

Use NoGen plan for unboxed-tuple bindings

There was a small mixup here, exposed by Trac #8762.
Now clarified with better function names and comments.

comment:5 Changed 6 years ago by simonpj

Status: newmerge
Test Case: typecheck/should_compile/T8762

Fixed, thank you.


comment:6 Changed 6 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.