JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
266 stars 32 forks source link

Improve error message for missing closing tokens #397

Closed c42f closed 7 months ago

c42f commented 7 months ago

When a missing closing token like ), ] or } is encountered we want the "Expected )" error to point to a location one past the last valid token, not to the trailing error tokens.

For example from #349 here's a poor error message from the existing code:

ERROR: ParseError:
# Error @ REPL[53]:15:5
    ylims!(p, (0, last(ylims(p)))
    xlabel!(p, "Contig length cutoff (kbp)")
#   └─────────────────────────────────────┘ ── Expected `)`

After this change, the error location instead points to the end of the last valid line:

ERROR: ParseError:
# Error @ REPL[53]:15:5
    ylims!(p, (0, last(ylims(p)))
#                                └── Expected `)`

Fix #349, fix #313

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (acb609d) 96.64% compared to head (d20307c) 95.83%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #397 +/- ## ========================================== - Coverage 96.64% 95.83% -0.81% ========================================== Files 14 13 -1 Lines 4172 3940 -232 ========================================== - Hits 4032 3776 -256 - Misses 140 164 +24 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tecosaur commented 4 months ago

A thought on this: when the tokes are paired, it could be helpful to highlight the corresponding un-paired token.

For example, here's some (lisp) code in my editor when I delete an opening paren:

image