Sven Panne writes:
> During the compilation of a small project with ghc-3.01 (Linux) I get:
>
> panic! (the `impossible' happened):
> unboxArg: PrelBase.(){-40-}
>
> The code leading to this error is available at:
>
> http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/impossible.tar.gz
>
Thanks, a bug alright; here's the offender:
useLayer :: Layer -> IO ()
useLayer gc_arg1 =
case (undefined gc_arg1) of { arg1 ->
_casm_ ``do {int arg1;
arg1 = %0;
do {glutUseLayer(arg1);} while(0);} while(0);'' arg1}
This shouldn't get past the type checker. The type checker is supposed
to default polymorphic _ccall_/_casm_ results to (). It is doing
something more general though, defaulting both (CCallable a => a) and
(CReturnable a => a) to (), i.e., polymorphic results _and_
arguments. The enclosed patch restricts this to results only.
I'm puzzled as to why this would only surface now with the
introduction of the MPC-capable type checker. ghc-2.10 doesn't accept
it, but it has the same defaulting code.
--Sigbjorn
*** ghc/compiler/typecheck/TcSimplify.lhs 1998/02/10 14:16:54 1.24
--- ghc/compiler/typecheck/TcSimplify.lhs 1998/03/05 19:19:23
***************
*** 147,151 ****
import Bag ( Bag, bagToList, snocBag )
import Class ( Class, ClassInstEnv, classBigSig, classInstEnv )
! import PrelInfo ( isNumericClass, isCcallishClass )
import Maybes ( maybeToBool )
--- 147,151 ----
import Bag ( Bag, bagToList, snocBag )
import Class ( Class, ClassInstEnv, classBigSig, classInstEnv )
! import PrelInfo ( isNumericClass, isCreturnableClass )
import Maybes ( maybeToBool )
***************
*** 926,932 ****
returnTc binds
! | all isCcallishClass classes
= -- Default CCall stuff to (); we don't even both to check that () is an
! -- instance of CCallable/CReturnable, because we know it is.
unifyTauTy (mkTyVarTy tyvar) unitTy `thenTc_`
returnTc EmptyMonoBinds
--- 926,932 ----
returnTc binds
! | all isCreturnableClass classes
= -- Default CCall stuff to (); we don't even both to check that () is an
! -- instance of CReturnable, because we know it is.
unifyTauTy (mkTyVarTy tyvar) unitTy `thenTc_`
returnTc EmptyMonoBinds
*** ghc/compiler/prelude/PrelInfo.lhs 1998/02/03 17:15:00 1.33
--- ghc/compiler/prelude/PrelInfo.lhs 1998/03/05 19:12:28
***************
*** 34,38 ****
needsDataDeclCtxtClassKeys, cCallishClassKeys, cCallishTyKeys, isNoDictClass,
! isNumericClass, isStandardClass, isCcallishClass
) where
--- 34,38 ----
needsDataDeclCtxtClassKeys, cCallishClassKeys, cCallishTyKeys, isNoDictClass,
! isNumericClass, isStandardClass, isCcallishClass, isCreturnableClass
) where
***************
*** 501,508 ****
isCcallishClass, isNoDictClass, isNumericClass, isStandardClass :: Class -> Bool
! isNumericClass clas = classKey clas `is_elem` numericClassKeys
! isStandardClass clas = classKey clas `is_elem` standardClassKeys
! isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
! isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
is_elem = isIn "is_X_Class"
--- 501,509 ----
isCcallishClass, isCreturnableClass, isNoDictClass, isNumericClass, isStandardClass
:: Class -> Bool
! isNumericClass clas = classKey clas `is_elem` numericClassKeys
! isStandardClass clas = classKey clas `is_elem` standardClassKeys
! isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
! isCreturnableClass clas = classKey clas == cReturnableClassKey
! isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
is_elem = isIn "is_X_Class"