Ticket #5458 (closed bug: fixed)

Opened 21 months ago

Last modified 21 months ago

Phantom types confuse SpecConstr

Reported by: simonpj Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: simplCore/should_compile/T5458 Blocked By:
Blocking: Related Tickets:

Description

This program

type T a = Int

f :: T a -> Bool -> [Int]
f x b = case b of
               True  -> f x b
               False -> x : f x (x > 19)

gave a Lint error in SpecConstr (use -O2). Reason: the specialised function was abstracted over x, but x's type mentions a phantom type variable a, and that wasn't being abstracted over.

Phantom type variables are a nuisance. A simple fix is to de-synonym the type of the abstracted variables.

Change History

Changed 21 months ago by simonpj@…

commit 69ecb07c635336b25fa4fc068424d4343db85549

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Mon Sep 5 08:32:07 2011 +0100

    Link the de-synonym change to ticket Trac #5458

 compiler/specialise/SpecConstr.lhs |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Changed 21 months ago by simonpj

  • status changed from new to closed
  • testcase set to simplCore/should_compile/T5458
  • resolution set to fixed

The main patch is this

commit e45c35fb4594668acfeeb7d9916c9b2eb03bbe22
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Mon Sep 5 08:16:58 2011 +0100

    De-synonym the types of the abtracted term variables in SpecConstr
    
    This was making Text.PrettyPrint.HughesPJ give a lint-bug
    when the libraries were compiled with -O2.
    
    It's all caused by phantom type synonyms (which are, generally
    speaking, a royal pain).  The fix is simple, but a bit brutal.
    
    See Note [Free type variables of the qvar types].

>---------------------------------------------------------------

 compiler/specialise/SpecConstr.lhs |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
Note: See TracTickets for help on using tickets.