whitequark / whitequark/parser

highlight line should handle case where size == 0

Open
#785 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Yacc
Stars
1.6k
Forks
205
PR merge metrics
No merged PRs in 30d

Description

Reproduction instructions:

irb(main):003:0> Parser::CurrentRuby.parse('foo++')
(string):1:6: error: unexpected token $end
(string):1: foo++
(string):1:
Traceback (most recent call last):
...

Note the blank line where there should be either a caret or a tilde indicating the spot of the error.

The code in question is in Parser::Diagnostic::render_line.

I'd submit a pull request, but it isn't clear to me whether the code should be putting out a caret or a tilde in this case. I have verified that column_range.begin_pos is the spot immediately after the end of the line in this case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction in the issue, then read lib/parser/diagnostic.rb at Parser::Diagnostic::render_line and inspect how a zero-sized column range is rendered. Decide whether the diagnostic should show a caret or tilde, and verify that the reproduced parse error no longer leaves a blank highlight line.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.