Opened 9 years ago

Closed 9 years ago

#4870 closed bug (fixed)

Compiler panic with SPECIALIZE pragma on function from imported module

Reported by: dreixel Owned by:
Priority: high Milestone: 7.2.1
Component: Compiler Version: 7.0.1
Keywords: Cc: jpm@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: deSugar/should_compile/T4870
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Consider the following two modules:

module Test1 where

class C a where c :: a -> a

{-# INLINE f #-}
f :: (C a) => a
f = c f
module Test2 where

import Test1

data D

instance C D

{-# SPECIALIZE f :: D #-}

ghc-7.0.1 invoked with -O Test2 results in

[1 of 2] Compiling Test1            ( Test1.hs, Test1.o )
[2 of 2] Compiling Test2            ( Test2.hs, Test2.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.0.1 for i386-unknown-mingw32):
        dsImpSpecs main:Test1.f{v r2} [gid]

This is a highly simplified example of a desired rewrite rule in the generic programming library Multirec. Note that there is no problem if the code is all in the same module.

Change History (3)

comment:1 Changed 9 years ago by igloo

Milestone: 7.0.3
Priority: normalhigh

Thanks for the report.

comment:2 Changed 9 years ago by simonpj

Status: newmerge
Test Case: deSugar/should_compile/T4870

Thanks for the example. Fixed by

Wed Jan  5 00:27:12 GMT 2011  simonpj@microsoft.com
  * Fix Trac #4870: get the inlining for an imported INLINABLE Id
  
  We need the unfolding even for a *recursive* function (indeed
  that's the point) and I was using the wrong function to get it
  (idUnfolding rather than realIdUnfolding).

    M ./compiler/deSugar/DsBinds.lhs -6 +7

Please merge to 7.0 branch

Simon

comment:3 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed

Merged.

Note: See TracTickets for help on using tickets.