Ticket #60 (closed bug report: fixed)

Opened 5 years ago

Last modified 5 years ago

Use prettyPrint over show for error messages

Reported by: nibro Owned by: nibro
Priority: major Milestone:
Component: parser Version: 1.1.4
Keywords: Cc:

Description (last modified by nibro) (diff)

From Lennart Augustsson:

If you parse the module

fun x = x + 1 +

with Language.Haskell.Exts.Annotated. parseFileContentsWithMode you get the error message

Parse failed at (2:1): Parse error in expression: PostOp (SrcSpanInfo
{srcInfoSpan = SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1,
srcSpanStartColumn = 9, srcSpanEndLine = 1, srcSpanEndColumn = 16},
srcInfoPoints = []}) (InfixApp (SrcSpanInfo {srcInfoSpan = SrcSpan
{srcSpanFilename = "", srcSpanStartLine = 1, srcSpanStartColumn = 9,
srcSpanEndLine = 1, srcSpanEndColumn = 14}, srcInfoPoints = []}) (Var
(SrcSpanInfo {srcInfoSpan = SrcSpan {srcSpanFilename = "",
srcSpanStartLine = 1, srcSpanStartColumn = 9, srcSpanEndLine = 1,
srcSpanEndColumn = 10}, srcInfoPoints = []}) (UnQual (SrcSpanInfo
{srcInfoSpan = SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1,
srcSpanStartColumn = 9, srcSpanEndLine = 1, srcSpanEndColumn = 10},
srcInfoPoints = []}) (Ident (SrcSpanInfo {srcInfoSpan = SrcSpan
{srcSpanFilename = "", srcSpanStartLine = 1, srcSpanStartColumn = 9,
srcSpanEndLine = 1, srcSpanEndColumn = 10}, srcInfoPoints = []}) "x")))
(QVarOp (SrcSpanInfo {srcInfoSpan = SrcSpan {srcSpanFilename = "",
srcSpanStartLine = 1, srcSpanStartColumn = 11, srcSpanEndLine = 1,
srcSpanEndColumn = 12}, srcInfoPoints = []}) (UnQual (SrcSpanInfo
{srcInfoSpan = SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1,
srcSpanStartColumn = 11, srcSpanEndLine = 1, srcSpanEndColumn = 12},
srcInfoPoints = []}) (Symbol (SrcSpanInfo {srcInfoSpan = SrcSpan
{srcSpanFilename = "", srcSpanStartLine = 1, srcSpanStartColumn = 11,
srcSpanEndLine = 1, srcSpanEndColumn = 12}, srcInfoPoints = []}) "+")))
(Lit (SrcSpanInfo {srcInfoSpan = SrcSpan {srcSpanFilename = "",
srcSpanStartLine = 1, srcSpanStartColumn = 13, srcSpanEndLine = 1,
srcSpanEndColumn = 14}, srcInfoPoints = []}) (Int (SrcSpanInfo
{srcInfoSpan = SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1,
srcSpanStartColumn = 13, srcSpanEndLine = 1, srcSpanEndColumn = 14},
srcInfoPoints = []}) 1 "1"))) (QVarOp (SrcSpanInfo {srcInfoSpan =
SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1, srcSpanStartColumn
= 15, srcSpanEndLine = 1, srcSpanEndColumn = 16}, srcInfoPoints = []})
(UnQual (SrcSpanInfo {srcInfoSpan = SrcSpan {srcSpanFilename = "",
srcSpanStartLine = 1, srcSpanStartColumn = 15, srcSpanEndLine = 1,
srcSpanEndColumn = 16}, srcInfoPoints = []}) (Symbol (SrcSpanInfo
{srcInfoSpan = SrcSpan {srcSpanFilename = "", srcSpanStartLine = 1,
srcSpanStartColumn = 15, srcSpanEndLine = 1, srcSpanEndColumn = 16},
srcInfoPoints = []}) "+")))

Maybe a show that should be a prettyPrint?

Indeed it should be, but this is a PExp being printed, and PExp (defined in ParseUtils?) doesn't instantiate Pretty. Not obvious how to do that in a nice way either, I'll have to think about it for a bit.

Change History

Changed 5 years ago by nibro

  • description modified (diff)

Changed 5 years ago by anonymous

  • status changed from new to closed
  • resolution set to fixed

I broke the loop by moving the PExp stuff into a separate internal ParseSyntax? module, which Pretty and ParseUtils? can both import. I now get

"Parse error in expression: x + 1 +"

Much nicer!

Note: See TracTickets for help on using tickets.