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

Repeated patterns in the same line don't have the correct column highlight #1565

Open
cg-jl opened this issue Jun 12, 2024 · 0 comments
Open

Comments

@cg-jl
Copy link
Contributor

cg-jl commented Jun 12, 2024

The column highlight for the "repeated patterns" error points incorrectly to the first pattern in the line, which
causes confusion:


fn main() {
   match 1u8 {
      b'a' | b'b' | b'b' => {}
      else => {}
   }
}

This produces the repeated patterns error, but both highlights (error and hint) are on b'a', which is not the repeated. The repeated pattern is b'b'.

Bad error message:

Error: Duplicated match pattern
────┬─ boog.jakt:4:10
 26 │     match 1u8 {
 27 │         b'a' | b'b' | b'b' => {}
    │          ──┬
    │            ╰─ Duplicated match pattern
 28 │         else => {}
────┴─
Hint: Original pattern here
────┬─ boog.jakt:4:10
 26 │     match 1u8 {
 27 │         b'a' | b'b' | b'b' => {}
    │          ──┬
    │            ╰─ Original pattern here
 28 │         else => {}
────┴─

Expected error message:

 Error: Duplicated match pattern
 ───┬─ boog.jakt:4:23    | <- notice how the column number changes here. This should be the only thing to test, really.
  3 │     match 1u8 {
  4 │         b'a' | b'b' | b'b' => {}                     
    │                       ──┬                            | notice how the offset in of the highlight is different, since it was moved
    │                         ╰─ Duplicated match pattern  | 
  5 │     }
 ───┴─
 Hint: Original pattern here
 ───┬─ boog.jakt:4:10
  3 │     match 1u8 {
  4 │         b'a' | b'b' | b'b' => {}                    
    │                ──┬                                  | I've also had to move the highlight here
    │                  ╰─ Original pattern here
  5 │     }
 ───┴─

Note that Jakttest currently doesn't support error message locations, only searching through their titles, so automating this test is not going to be pretty (if it is done) for the moment.

@cg-jl cg-jl changed the title Inline repeated patterns don't have the correct column highlight Repeated patterns in the same line don't have the correct column highlight Jun 12, 2024
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

No branches or pull requests

1 participant