REPL command parse errors are unhelpful
In the REPL, the parser does not differentiate in any significant way between commands and ordinary terms to evaluate. This means that when an incorrect command is entered, the REPL then tries to parse it as a term, and gives a term-like error. (As far as I can tell, the error is the same in all cases: "no implicit arguments allowed here, expected: dependent type signature, end of input". Which sounds like it's interpreting the : as the : that appears before a type signature.)
Examples:
:exec main
Shows the above error. :exec is a valid command, and does approximately what someone who wrote :exec main probably wants.
I'll try to edit this with more examples soon, but I don't have a working idris at the moment.
It seems like a nice way to fix this would be to case on the first character of the REPL's input string, before calling any parser:
- Is it
:? Invoke a specialized parser for repl commands:- Look at the first word (after the
:). If it matches any command, use that to look up the parser for the rest of the input line. - If it doesn't match any command, see if it gets close, and offer spelling suggestions.
- Look at the first word (after the
- Otherwise, run the same parser as we have now.
I meant to mark this as low-hanging fruit, but I don't see how. If someone can do that after the fact, that would be nice.
Done!
I'm poking around at this.
Looks like this was already fixed in 8fc9ffd6 if I am not mistaken?
Yes, I believe this much better in 0.9.19.1 (current master) than @trillioneyes' initial description.
> :exec main
Hello Idris devs!
> :exec m
When checking argument value to function Prelude.Basics.the:
No such variable m
:help indicates :exec can accept an expression.
:exec :execute [<expr>] Compile to an executable and run
Unless there are objections, I think we can close this one.