Skip to content

Parse errors should display text being parsed

(More general form of part of #3805 (closed))

Typical parse error:

TestErr.hs:1:0: Invalid type signature

Typical type error:

TestErr.hs:2:6:
    Couldn't match expected type `Int' against inferred type `[Char]'
    In the expression: "x"
    In the definition of `foo': foo = "x"

That explicit description of which expression was being examined is frequently useful in quickly understanding an error that occurs in the middle of a complex piece of code. There's no obvious reason why we can't have the same sort of thing on all parse errors - a quick glance at the parser suggests it's already tracking the byte range, so it should be fairly straightforward. I'd like to see this (on all parse errors, not just this one):

TestErr.hs:1:0:
    Invalid type signature
    While trying to parse: `foreign export ccall foo :: IO ()'
Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Parser)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information