Skip to content

Lexer is too permissive with numbers followed by an identifier (e.g. "1foo")

Summary

GHC's lexer lexes numbers followed by an identifier as two separate tokens (number and then identifier) when I think it should reject this as invalid.

Steps to reproduce

GHCi, version 9.8.1: https://www.haskell.org/ghc/  :? for help
ghci> foo = 1
ghci> (+) 1foo
2

Expected behavior

I would expect the lexer to throw an error.

Environment

  • GHC version used: 9.8.1

Optional:

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