Opened 6 years ago

Closed 5 years ago

#5366 closed bug (fixed)

UNPACK is paranoid about a phantom type argument

Reported by: ekmett Owned by:
Priority: normal Milestone: 7.6.2
Component: Compiler Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: simplCore/should_compile/T5366
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Attempting to use code with a phantom type like the following:

newtype Id a = Id Int

inlines fine into

data Foo = Foo {-# UNPACK #-} !(Id Foo) String

but when I go to inline THAT

data Bar = Bar {-# UNPACK #-} !Foo

GHC tells me no, even though the recursive use of Foo is only through a phantom type.

Distilled.hs:3:12:
    Warning: Ignoring unusable UNPACK pragma on the
             first argument of `Bar'
    In the definition of data constructor `Bar'
    In the data type declaration for `Bar'

Change History (3)

comment:1 Changed 6 years ago by igloo

Milestone: 7.6.1

The root of the problem is that chooseBoxingStrategy in typecheck/TcTyClsDecls.lhs thinks that Foo is a recursive type.

comment:2 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:3 Changed 5 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: simplCore/should_compile/T5366

Fixed in HEAD; see the commit for Trac #3990

Note: See TracTickets for help on using tickets.