Can't get pretty error printing in `Meta.parse()`

showerror doesn’t seems to work for Meta.parse(). For example, when i type 5 sin I get a nice messge.

julia> 5 sin
ERROR: syntax: extra token "sin" after end of expression

But if I type Meta.parse("5 sin") it doesn’t look so good.

julia> Meta.parse("5 sin")
ERROR: Base.Meta.ParseError("extra token \"sin\" after end of expression")

Is it supposed to be like this?
And how can i convert this error to a nice error string? (I am trying to convert errors to pretty string with sprint(showerror, error), and it doesn’t work with Base.Meta.ParseError)

1 Like

No, I don’t think so - there’s no method for Meta.ParseError (you can check by going through the list methods(showerror)).

The first “pretty printing” is done by the parser itself, I think. Meta.parse just calls into the parser, which seems to return the ParseError object.

Could you open an issue for this?

1 Like

Thanks for the reply!

No, I don’t think so - there’s no method for Meta.ParseError

Yes, maybe they forgot to add a method for this error.

Could you open an issue for this?

Yes, good idea

1 Like

Opened a new issue
https://github.com/JuliaLang/julia/issues/45730

2 Likes