modus icon indicating copy to clipboard operation
modus copied to clipboard

Misleading error message `expected ")"`

Open maowtm opened this issue 2 years ago • 1 comments

a :-
  (
    (
      b("aaa")
      c("aaa")
    ), d).
error: expected ")"
  ┌─ aaa:5:7
  │    
1 │   ╭ a :-
2 │ ╭ │   (
3 │ │ │     (
4 │ │ │       b("aaa")
5 │ │ │       c("aaa")
  │ │ │       ^
  │ ╰─│───────' in section "rule_body"
  │   ╰───────' in section "rule"

@thevirtuoso1973 is it possible to say something like expected "," or ")" by any chance?

maowtm avatar Mar 06 '22 00:03 maowtm

Yes, in a way. I could rewrite the expression parser to be more like parsing binary operators. Then at some point we'll have alt((another_operator, parentheses_close_expression)) and if I cut(alt(...)) then the generated tree should store the alternatives so it would look something like this:

expected ")"
  ┌─ aaa:5:7
  │    
...
or
expected ","
  ┌─ aaa:5:7
  │    
...

Although I probably won't do this now.

thevirtuoso1973 avatar Mar 06 '22 11:03 thevirtuoso1973