Opened 3 years ago

Closed 15 months 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 Difficulty: Unknown
Test Case: simplCore/should_compile/T5366 Blocked By:
Blocking: Related Tickets:

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 2 years ago by igloo

  • Milestone set to 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 19 months ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:3 Changed 15 months ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to simplCore/should_compile/T5366

Fixed in HEAD; see the commit for Trac #3990

Note: See TracTickets for help on using tickets.