Skip to content

Worker wrapper incorrectly calculates max-worker-args for unboxed tuples.

For the type T in the code below worker-wrapper will happily unbox MkT since it assumes MkT only has one field.

But the unboxed tuple actually represents 10 arguments at runtime.

Here is the code:

data T = MkT (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int #)

{-# NOINLINE f #-}
f :: Int -> (# Int, Int #) -> T -> Int
f x (# y, z #) (MkT (# x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 #)) = x + y + z + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10

---- worker type in core:
-- RHS size: {terms: 62, types: 75, coercions: 0, joins: 0/0}
M.$wf [InlPrag=NOINLINE]
  :: GHC.Prim.Int#
     -> GHC.Prim.Int#
     -> GHC.Prim.Int#
     -> (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int #)
     -> GHC.Prim.Int#
[GblId,
 Arity=4,
 Str=<L><L><L><1P(1L,1L,1L,1L,1L,1L,1L,1L,1L,1L)>,
 Unf=OtherCon []]
M.$wf

Maybe not worth fixing but it's a interesting edge case.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information