Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for missing closing tokens #397

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

c42f
Copy link
Member

@c42f c42f commented Dec 5, 2023

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

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 `)`
Copy link

codecov bot commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@c42f c42f merged commit a6f2d15 into main Dec 5, 2023
27 of 32 checks passed
@c42f c42f deleted the caf/fix-missing-closer-or-comma-message branch December 5, 2023 11:01
c42f added a commit that referenced this pull request Dec 6, 2023
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 `)`
@tecosaur
Copy link

tecosaur commented Feb 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Underbracket placement better error message for missing comma.
2 participants