Skip to content

OverloadedLabels "lexical error in pragma" when using a bare number

When OverloadedLabels is in use, if a label is immediately followed by a digit in a GHCi expression, a "lexical error in pragma" message results, even though this should be parsed successfully:

GHCi, version 9.8.0.20230727: https://www.haskell.org/ghc/  :? for help
ghci> :set -XOverloadedLabels
ghci> :t #x
#x :: GHC.OverloadedLabels.IsLabel "x" a => a
ghci> :t #2

<interactive>:1:2: error: [GHC-21231]
    lexical error in pragma at character '2'

Surrounding the label in parentheses works around the problem, and it doesn't seem to happen for non-digit characters:

ghci> :t (#2)
(#2) :: GHC.OverloadedLabels.IsLabel "2" a => a
ghci> :t #'
#' :: GHC.OverloadedLabels.IsLabel "'" a => a
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information