Skip to content

Misplaced SPECIALISE instance pragma has poorly formatted error message (8.10.1+)

If you compile this program with GHC 8.10.1 or later:

module Bug where

{-# SPECIALISE instance Show String #-}

You'll get this error message:

$ /opt/ghc/8.10.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:3:1: error:
    Misplaced {-# SPECIALISE instance pragma:
    {-# SPECIALISE instance Show String #-}
  |
3 | {-# SPECIALISE instance Show String #-}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Notice the "Misplaced {-# SPECIALISE instance pragma" part, which is missing a closing #-}. This is a regression from GHC 8.8.3, which prints this error message:

$ /opt/ghc/8.8.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:3:1: error:
    Misplaced SPECIALISE instance pragma:
    {-# SPECIALISE instance Show String #-}
  |
3 | {-# SPECIALISE instance Show String #-}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

git blame reveals that the responsible commit is 6f4c1250. cc'ing @alinab

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