Skip to content

[red-knot] MDTest parsing problems #15923

@sharkdp

Description

@sharkdp

Description

Unfortunately, I only noticed this after merging #15890 when I worked on some tests. This looks like a regression. In the following file, the code snippet will not be detected and never executed. In a larger file, this could easily lead to mistakes where someone writes a test that seems to succeed.

This "succeeds" on main, but failed with "unexpected error: [invalid-syntax]" before merging pre-#15890 (as it should):

# My test

No newline between prose and code:
```py
# A syntax error:
;
```

While writing a MRE for this bug, I also found this weird behavior which definitely looks like a bug. When the ; in the example above is replaced with §, I get:

thread 'mdtest__binary_integers' panicked at crates/ruff_python_trivia/src/cursor.rs:138:41:
byte index 1 is not a char boundary; it is inside '§' (bytes 0..2) of `§
```
`

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtyMulti-file analysis & type inference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions