Commit f117d08b authored by's avatar
Browse files

Fix Trac #1037

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. 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.
parent b0d80aa3
......@@ -1163,13 +1163,11 @@ isFFIDotnetTy dflags ty
-- it no longer does so. May need to adjust isFFIDotNetTy
-- if we do want to look through newtypes.
isFFIDotnetObjTy ty =
isFFIDotnetObjTy ty
= checkRepTyCon check_tc t_ty
(_, t_ty) = tcSplitForAllTys ty
case tcSplitTyConApp_maybe (repType t_ty) of
Just (tc, [arg_ty]) | getName tc == objectTyConName -> True
_ -> False
check_tc tc = getName tc == objectTyConName
toDNType :: Type -> DNType
toDNType ty
......@@ -1252,7 +1250,11 @@ legalFFITyCon tc
= isUnLiftedTyCon tc || boxedMarshalableTyCon tc || tc == unitTyCon
marshalableTyCon dflags tc
= (dopt Opt_UnliftedFFITypes dflags && isUnLiftedTyCon tc)
= (dopt Opt_UnliftedFFITypes dflags
&& isUnLiftedTyCon tc
&& case tyConPrimRep tc of -- Note [Marshalling VoidRep]
VoidRep -> False
other -> True)
|| boxedMarshalableTyCon tc
boxedMarshalableTyCon tc
......@@ -1267,3 +1269,12 @@ boxedMarshalableTyCon tc
, boolTyConKey
Note [Marshalling VoidRep]
We don't treat State# (whose PrimRep is VoidRep) as marshalable.
In turn that means you can't write
foreign import foo :: Int -> State# RealWorld
Reason: the back end falls over with panic "primRepHint:VoidRep";
and there is no compelling reason to permit it
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment