Support for displaying non-identifier characters in help via #19858

I love @stevengj new PRs that just got merged, just found a minor problem though:

help?> ⊻
"⊻" can be typed by \xor<tab>
help?> †
ERROR: Invalid @var syntax `invalid character "†"`.

This is unrelated to PR #19858: a similar error message occurs in Julia 0.5 and 0.4, because (\dagger) is currently not allowed in identifiers. There are two separate issues here:

First, whether the REPL help should print something more helpful if you enter an invalid identifier, rather than throwing an error (although the error message is somewhat informative).

Second, whether should be allowed in identifiers. It wasn’t added when support for other Unicode math symbols was added to the parser, because it wasn’t clear whether we should parse it as part of identifiers or as an operator. (My inclination would be to parse it as an identifier character, since we already have a' for the adjoint.)

OK, but I’d say that it is an implementation detail that the display in Help of how to type a particular character via LaTeX (or Emoji) tab completion via #19858 only displays that information for valid identifiers.

I hadn’t intended at all to bring up any issues of whether or not \dagger is a valid identifier.
I was strictly thinking of the usefulness of being able to paste any character at the help?> prompt and easily find out how to type it.

Also, please don’t edit the topic into something that had nothing to do with what I’d intended (I just used \dagger as an example, not for any other reason, what I brought up had nothing to do with whether it was an identifier or not - and the error message did not at all indicate that).

Sorry, I had to guess at your intent in order to make a clearer title, since the error message was a pre-existing one that had nothing to do with #19858.

At the time I posted, I had no idea that it had anything to do with identifier vs. non-identifier, or that it was a pre-existing error message. I was just trying to raise the issue that it hadn’t worked as I’d expected. Your now happily merged PRs are very nice additions to Julia, just trying to help out with a bit of user testing!

Changing the thread title is not an attack on you, Scott. It’s just that the error is not about what you thought it was about, so a different title clarifies the thread: when something is reported as “error in foo” when it is actually “error in baz”, then a retitle is appropriate, even though the (refocused) discussion remains welcome.

As I said in my initial response, both the help output and the handing of could be improved and your feedback in that regard is welcome.

No, I didn’t say it was an attack!
I just think it’s better to leave those alone while things are still unclear, they can be changed if things are clearer later.
(hopefully the current topic title is clear enough now)
That’s all!

I guess maybe before changing a topic title, a message saying: “This seems unclear, did you mean X or Y?” would be nice.

I now have a branch that fixes this (and another related problem), as well as eliminating that unhelpful error message when you ask for help on something that isn’t a valid expression).
https://github.com/ScottPJones/julia/tree/spj/improvehelp

It turns out that both repl_latex (added by #19858) and repl_search were being called from the wrong place, in the method repl(io::IO, s::Symbol), after the line after the ? has already been parsed into an AST (which ended up being :($(Expr(:error, "invalid character \"†\""))) with the dagger character example).

Could you possibly make a PR from my branch?

Thanks again for doing #19858!