Skip to content

Imprecise source spans for erroneous flags in OPTIONS_GHC

If I say

{-# OPTIONS_GHC -this-doesnt-exist -neither-does-this #-}

module Bug where

I get

Bug.hs:1:16: error:
    unknown flag in  {-# OPTIONS_GHC #-} pragma: -this-doesnt-exist
  |
1 | {-# OPTIONS_GHC -this-doesnt-exist -neither-does-this #-}
  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Bug.hs:1:16: error:
    unknown flag in  {-# OPTIONS_GHC #-} pragma: -neither-does-this
  |
1 | {-# OPTIONS_GHC -this-doesnt-exist -neither-does-this #-}
  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note that both errors have the same location and both caret-diagnostics show the whole list of flags.

Getting this wrong means that the errors get ordered unpredictably.

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