PLC-lang / PLC-lang/rusty

Improve reporting multiple issues for the exact same location

Open
#962 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue low-priority
Dominant language
Rust
Stars
362
Forks
75
Avg merge
6d 9h
Merged PRs (30d)
35

Description

Some situations report multiple issues for the exact same location. They get reported as independant issues and it is hard to see that th e last three are probably just follow up errors of the first one:

error: Unexpected token: expected DataTypeDefinition but found KeywordAbstract
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected DataTypeDefinition but found KeywordAbstract

error: Unexpected token: expected Datatype but found ABSTRACT
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected Datatype but found ABSTRACT

error: Unexpected token: expected Literal but found ABSTRACT
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected Literal but found ABSTRACT

error: Unexpected token: expected KeywordSemicolon but found 'ABSTRACT'
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected KeywordSemicolon but found 'ABSTRACT'

We should try to group diagnostics by their location before we report them. Something like this:

error: Unexpected token: expected DataTypeDefinition but found KeywordAbstract (+ 3 additional)
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ 1. Unexpected token: expected DataTypeDefinition but found KeywordAbstract
  │                                       2. Unexpected token: expected Datatype but found ABSTRACT
  │                                       3. Unexpected token: expected Literal but found ABSTRACT
  │                                       4. Unexpected token: expected KeywordSemicolon but found ABSTRACT

Contributor guide

No contributing guide indexed for this repository

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 by tracing how parser diagnostics are collected and rendered. Group diagnostics sharing an exact location, preserve the first as the primary message, and render the remaining diagnostics as additional messages; verify the output against the example in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.