Skip to content

Bug: formatting a multiline string twice gets changing results #11724

@jasikpark

Description

@jasikpark

This was found via the fuzz/ruff_formatter_idempotency.rs fuzz target; It should be reproducible with standard ruff format.

Ruff was built from source around (2b28889)

Original code:


'''
\u{15}

'''

Formatted once:

"""
u{15}
"""

Formatted twice:

"""
u{15}"""

Original fuzz crash error:

thread '<unnamed>' panicked at fuzz_targets/ruff_formatter_idempotency.rs:31:17:

Reformatting the code a second time resulted in formatting changes.
Input: "\n'''\n\u{15}\n\n'''"
First: "\"\"\"\n\u{15}\n\"\"\"\n"

Second: "\"\"\"\n\u{15}\"\"\"\n"
diff:
--- Formatted Once
+++ Formatted Twice
@@ -1,3 +1,2 @@
 """
-
-"""
+"""

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingformatterRelated to the formatter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions