[GHC] #14742: Unboxed sums can treat Word#s as Int#s
GHC
ghc-devs at haskell.org
Wed Jan 31 07:21:19 UTC 2018
#14742: Unboxed sums can treat Word#s as Int#s
-------------------------------------+-------------------------------------
Reporter: duog | Owner: osa1
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Resolution: | Keywords: UnboxedSums
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by osa1):
I think this is by design and we should relax the STG lint check if it's
becoming a problem (or maybe we can add a special case for unboxed sums).
The whole point of unboxed sums is to have a compact and unboxed layout.
Compactness here means same memory slot (in registers or stack or heap
locations) should be able to used for values of different types.
`primRepSlot` is what decides what slots can a value be put into in an
unboxed sum, and mapping larger number of prim reps to smaller number of
slot types means we can share same slot for values of different types/prim
reps.
This seemingly ill-typed STG happens because we have to give unboxed sum
data cons types, but we can't really say "anything that fits into a word
slot" in our current type system, so we give it the type `Word`. This
leads to seemingly ill-typed STG.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14742#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list