Skip to content

[Linter panic] failing to parse odd f-string f"{x, y=}" #6831

@Zac-HD

Description

@Zac-HD
x = 1
y = 2
z = f"{x, y=}"  # This is a weird but valid f-string, which crashes ruff
print(z)
% python repro.py
x, y=(1, 2)

% ruff --version
ruff 0.0.285

% ruff --isolated repro.py 
warning: Linting panicked repro.py: 

panicked at 'byte index 18446744073709551615 is out of bounds of `x, y=`', crates/ruff_python_parser/src/string.rs:321:30
Backtrace:    0: _rust_eh_personality
   1: _main
   2: _rust_eh_personality
   3: _rust_eh_personality
   4: _rust_eh_personality
   5: _rust_eh_personality
   6: __rjem_je_witnesses_cleanup
   7: _main
   8: __rjem_je_witnesses_cleanup
   9: _main
  10: _main
  11: _main
  12: _main
  13: _main
  14: _main
  15: _main
  16: _main
  17: _main
  18: _main
  19: _main
  20: _main
  21: __mh_execute_header
  22: __mh_execute_header
  23: _main

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingparserRelated to the parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions