Ticket #7101 (closed bug: fixed)

Opened 10 months ago

Last modified 9 months ago

Specialise broken for implicit parameters

Reported by: pcapriotti Owned by:
Priority: normal Milestone: 7.6.1
Component: Compiler Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty: Unknown
Test Case: simplCore/should_run/T7101 Blocked By:
Blocking: Related Tickets:

Description

The tcrun019 test case is failing with optimization on. Here is an even simpler test case:

{-# LANGUAGE ImplicitParams, RankNTypes #-}

module Main where

f :: (?x :: Int) => ((?x :: Int) => Int) -> Bool -> Int
f g False = g
f g True = let ?x = ?x + 1
           in f g False

h :: (?x :: Int) => Int
h = ?x

main :: IO ()
main = print (let ?x = 0 in f h True)

What happens is that f gets incorrectly specialized, and, as a result, the recursive call to f uses the old binding for the implicit parameter.

I think the problem was introduced with the refactoring in 5a8ac0f823c151c062a3f1903574030423bb255c, which broke the test for implicit parameter constraints in Specialise.lhs.

The attached patch seems to fix it.

Attachments

implicit.patch Download (1.0 KB) - added by pcapriotti 10 months ago.

Change History

Changed 10 months ago by pcapriotti

Changed 9 months ago by simonpj@…

commit 2f08f709cfdace23a4e32d80a57af349f7cc785a

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Thu Aug 23 16:35:55 2012 +0100

    Don't specialise on implicit-parameter arguments in Specalise
    
    This is a fix for Trac #7101

 compiler/specialise/Specialise.lhs |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

Changed 9 months ago by simonpj

  • status changed from new to merge
  • testcase set to simplCore/should_run/T7101

Good catch Paolo!

Changed 9 months ago by pcapriotti

  • status changed from merge to closed
  • resolution set to fixed

Merged as 20b25bc688b7a6257cb466d9c70c214dafa369c6.

Note: See TracTickets for help on using tickets.