Skip to content

"Can't find interface-file declaration" error when using a large tuple in a data type

The following programs all report rather cryptic error messages on GHC 8.2 or later:

  • module Bug1 where
    
    data T1 = MkT1
      ( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int
      )
    $ /opt/ghc/8.10.2/bin/ghc Bug1.hs
    [1 of 1] Compiling Bug1             ( Bug1.hs, Bug1.o )
    
    Bug1.hs:1:1: error:
        Can't find interface-file declaration for variable GHC.Tuple.$tc(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
          Probable cause: bug in .hi-boot file, or inconsistent .hi file
          Use -ddump-if-trace to get an idea of which file caused the error
      |
    1 | module Bug1 where
      | ^
  • {-# LANGUAGE DataKinds #-}
    module Bug2 where
    
    import Data.Proxy
    
    data T2 = MkT2 (Proxy
     '( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int
      ))
    $ /opt/ghc/8.10.2/bin/ghc Bug2.hs
    [1 of 1] Compiling Bug2             ( Bug2.hs, Bug2.o )
    
    Bug2.hs:1:1: error:
        Can't find interface-file declaration for variable GHC.Tuple.$tc(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
          Probable cause: bug in .hi-boot file, or inconsistent .hi file
          Use -ddump-if-trace to get an idea of which file caused the error
      |
    1 | {-# LANGUAGE DataKinds #-}
      | ^
  • {-# LANGUAGE UnboxedTuples #-}
    module Bug3 where
    
    data T3 = MkT3
     (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int
      #)
    $ /opt/ghc/8.10.2/bin/ghc Bug3.hs
    [1 of 1] Compiling Bug3             ( Bug3.hs, Bug3.o )
    
    Bug3.hs:1:1: error:
        Can't find interface-file declaration for variable GHC.Types.$tc(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#)
          Probable cause: bug in .hi-boot file, or inconsistent .hi file
          Use -ddump-if-trace to get an idea of which file caused the error
      |
    1 | {-# LANGUAGE UnboxedTuples #-}
      | ^

Interestingly, the following programs do not throw a "Can't find interface-file declaration" error:

  • {-# LANGUAGE ConstraintKinds #-}
    module Bug4 where
    
    import Data.Proxy
    
    data T4 = MkT4 (Proxy
     (( Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      , Show Int, Show Int, Show Int
      )))
    $ /opt/ghc/8.10.2/bin/ghc Bug4.hs
    [1 of 1] Compiling Bug4             ( Bug4.hs, Bug4.o )
    
    Bug4.hs:7:3: error:
        • Constraint tuple arity too large: 63 (max arity = 62)
            Instead, use a nested tuple
        • In the first argument of ‘Proxy’, namely
            ‘((Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
               Show Int, Show Int, Show Int))’
          In the type ‘(Proxy ((Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int, Show Int,
                                Show Int, Show Int, Show Int, Show Int, Show Int)))’
          In the definition of data constructor ‘MkT4’
      |
    7 |  (( Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int, Show Int
      |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

    The reason is that there is a dedicated validity check for large constraint tuples in GHC.Tc.Gen.HsType.finish_tuple, unlike for boxed or unboxed tuples.

  • module Bug5 where
    
    f ::
      ( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
      , Int, Int, Int
      )
    f =
      ( 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
      , 123, 123, 123
      )
    $ /opt/ghc/8.10.2/bin/ghc Bug5.hs
    [1 of 1] Compiling Bug5             ( Bug5.hs, Bug5.o )
    
    Bug5.hs:13:3: error:
        A 63-tuple is too large for GHC
          (max size is 62)
          Workaround: use nested tuples or define a data type
       |
    13 |   ( 123, 123, 123, 123, 123, 123, 123, 123, 123, 123
       |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

    Using an overly large tuple expression fails because there is a dedicated validity check (GHC.Rename.Utils.checkTupSize) that is used when renaming tuple expressions and patterns. Curiously, the same check is not used when renaming tuple types.

  • module Bug6 where
    
    data T6 = MkT6
      ((,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int Int Int Int Int Int Int Int
       Int Int Int)
    $ /opt/ghc/8.10.2/bin/ghc Bug6.hs
    [1 of 1] Compiling Bug6             ( Bug6.hs, Bug6.o )
    
    Bug6.hs:4:4: error:
        A 63-tuple is too large for GHC
          (max size is 62)
          Workaround: use nested tuples or define a data type
      |
    4 |   ((,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
      |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    This is because GHC goes through a different code path when renaming prefix applications of tuple types than when renaming mixfix tuple types, and the code for renaming prefix applications of tuple types uses checkTupSize.

Perhaps we should use checkTupSize when renaming mixfix tuple types in rnHsTyKi?

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