Ticket #2562 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

GADTs: (.text+0xc6): undefined reference to `Main_IsEqual_con_info'

Reported by: igloo Owned by:
Priority: normal Milestone: 6.10.1
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

With this module:

{-# LANGUAGE ScopedTypeVariables, GADTs #-}

import Unsafe.Coerce

data IsEqual a b where
    IsEqual :: IsEqual a a

contextsEqual :: cxt1 -> cxt2 -> IsEqual cxt1 cxt2
contextsEqual = unsafeCoerce IsEqual

data Seq from to where
    Nil :: Seq here here

foo :: forall from to . Seq from to
foo = f undefined undefined
    where f :: from -> to -> Seq from to
          f x y = case contextsEqual x y of
                  IsEqual -> Nil

main :: IO ()
main = case foo :: Seq () () of
           Nil -> return ()

I get:

$ ghc --make z -fforce-recomp -O
[1 of 1] Compiling Main             ( z.hs, z.o )
Linking z ...
z.o: In function `smk_info':
(.text+0xc6): undefined reference to `Main_IsEqual_con_info'
collect2: ld returned 1 exit status

with the HEAD and 6.8.2.

Change History

Changed 5 years ago by simonpj

My compiler, compiled with -DDEBUG, gets an assert error.

What do you expect? You're doing

(unsafeCoerce IsEqual) undefined undefined

that is, applying a non-function as a function. Would you prefer a seg fault? Unsafe coerce is, as it says, unsafe.

What would be the right behaviour? A type error? Presumably not, since you have consciously suppressed that.

Simon

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to invalid

Whoops, you're quite right! I meant to say

contextsEqual _ _ = unsafeCoerce IsEqual

which works fine; sorry for the noise!

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.