Better desugaring failures when boxing fails
The new type-vs-constraint patch (!8750 (merged)), when it lands, allows us to do things like
[ I# (x2 +# y2) | I# x <- xs, let x2 = x +# 1 | I# y <- ys, let y2 = y -# 1 ]
This is a parallel list comprehension where we want to collect a bunch of pairs (x2,y2)
, but we can't make a pair of unboxed values. So we box them before building the pair.
- This is done in
GHC.Core.Make.wrapBox
and friends. - See also
Note [Boxing constructors]
in GHC.Builtin.Types
But
- We can't (currently) guarantee to do this - notably for nested unboxed tuples.
- If we fail to box, GHC crashes
But really we should make the desugarer stop with a civilised error message.
Should not be hard, but requires some careful attention to the various call sites of mkBigCoreTup
etc.
Closely related ticket: #21165 (closed)