Ticket #1037 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

primRepHint:VoidRep

Reported by: igloo Owned by:
Priority: normal Milestone: 6.8.1
Component: Compiler (FFI) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: ccfail001 Blocked By:
Blocking: Related Tickets:

Description

Compiling this module:

module Q where 

import GHC.Base

type World__ = State# RealWorld

foreign import ccall unsafe "putwchar" f :: World__ -> Char# -> World__

with ghc -fglasgow-exts -O Q.hs panics:

ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for x86_64-unknown-linux):
        primRepHint:VoidRep

It looks like we need a VoidHint if we want to support this.

Reported by John Meacham in  http://www.haskell.org/pipermail/glasgow-haskell-users/2006-November/011658.html

Change History

Changed 6 years ago by simonmar

I think the typechecker ought to be rejecting this foreign declaration, I don't believe State# is supposed to be among the valid return types for a foreign import. Why can't IO () be used here?

Changed 6 years ago by igloo

The time this sort of stuff is desirable is when you want to return unboxed values in the IO monad, as you can't have an IO Char# type.

However, the optimiser will currently eliminate the boxing done by the generated import wrapper and the unboxing done in the Haskell code that uses the import.

So it's not vital that this is done, but it would mean people don't have to rely on the optimiser always catching this sort of thing. It is only useful if you are writing (or generating) very low level stuff, though.

Changed 6 years ago by simonpj

  • status changed from new to closed
  • testcase set to ccfail001
  • resolution set to fixed

It makes *sense* for a foreign import to have a zero-sized return, thus

    foreign import ccall foo :: Int -> State# RealWorld

but it's not clear that it's useful, and it requires some back-end (a Hint for void types) to make it go right through the back end. It's not clear that we really want this facility, so rather than fixing the code generator, I'm just making the construct illegal for now.

Changed 6 years ago by igloo

  • milestone changed from 6.8 branch to 6.8.1

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.