Javascript backend: RuntimeRep handling
I was looking at StgToJS
and found some suspicious code around RuntimeRep
s.
To set the stage: parameters r
to constructs such as TYPE r
(when describing a type's kind) or (#,#) @r1 @r2
are special, because they describe a runtime representation. But aside from that, RuntimeRep
is just a regular data type; GHC should never do anything special just because a type has that kind. Rather, any special handling should be done based on the fact that a RuntimeRep
is used in a position describing the runtime representation.
As a consequence, every call to isRuntimeRepKinded
here violates this rule:
GHC/HsToCore/Foreign/JavaScript.hs: | isRuntimeRepKindedTy result_ty = panic "boxJsResult: runtime rep ty" -- fixme
GHC/HsToCore/Foreign/JavaScript.hs: | isRuntimeRepKindedTy result_ty = return (Nothing, id) -- fixme this seems like a hack
GHC/StgToJS/CoreUtils.hs:typeVt t | isRuntimeRepKindedTy t = []
GHC/StgToJS/CoreUtils.hs: | isRuntimeRepKindedTy ut = VoidV
GHC/StgToJS/Expr.hs: args = filter (not . isRuntimeRepKindedTy . idType) args0
The last check, isRuntimeRepKindedTy . idType
looks wrong: an Id has a type whose kind should be either TYPE sth
or CONSTRAINT sth
- it cannot be RuntimeRep
.
Low priority - this is cleanup only.