Weird parsing in presence of ExtendedLiterals
Summary
I was thinking how various language extensions change the tokenization and parsing of e.g. 123#Int
from Haskell2010
to Magic#
to the new ExtendedLiterals
. Especially if you also turn on RequiredTypeArguments
, nowadays the first two can be made to type-check. So I experimented and was surprised to uncover this:
Steps to reproduce
{-# LANGUAGE MagicHash, ExtendedLiterals, RequiredTypeArguments #-}
module Ex where
import GHC.Exts (Int#)
f :: Int# -> forall t -> ()
f _ _ = ()
x = f 0x80#Int
x3 = f 0x80#Int3
--x8 = f 0x80#Int8
With GHC 9.10.1, the above program compiles with no errors. Note there is no type Int3
nor Int3#
in scope or anywhere at all, so this should fail even before type-checking. The last line if uncommented does trigger a proper error, saying the expression is of type GHC.Prim.Int8#
.
Expected behavior
Report an error for the first line, something like There is no type Int3# in scope. It's not clear if the first line should type-check or not, so it would be nice to have that clarified in the user guide.
Environment
- GHC version used: 9.10.1