Skip to content

Misleading error message when unboxed tuples used in sums without -XUnboxedTuples

$ cat lib.hs
{-# LANGUAGE UnboxedSums #-}

module Lib where

type Foo = (# (# Int, Int #) | Int #)

$ ghc lib.hs
[1 of 1] Compiling Lib              ( lib.hs, lib.o )

lib.hs:5:1: error:
    • Illegal unboxed tuple type as function argument: (# Int, Int #)
    • In the type synonym declaration for ‘Foo’
  |
5 | type Foo = (# (# Int, Int #) | Int #)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But there's nothing illegal about this type, we just need to enable UnboxedTuples. The error message is misleading.

(We should also check using unboxed sums inside tuples)

Edited by Ömer Sinan Ağacan
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information