Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Formatter rewrites Lisette f-strings to multiline interpolation that…

  1. User

    ISSUE DESCRIPTION

    Formatter rewrites Lisette f-strings to multiline interpolation that the compiler rejects lis build rejects multiline interpolation expressions inside f"...{...}" strings, but Zed’s Lisette formatter appears to rewrite single-line calls across lines automatically.

    Example:

    f"You cannot use another ender pearl for {shared.format_duration(
      remaining,
    )}."
    

    The compiler reports:

    [error] Multi-line f-string interpolation
    ...
    error: f-string interpolations must be single-line
    

    Impact:

    • lis build fails after formatting in touched spots.
    • This forces manual one-line edits to pass build.

    Expected:

    • Either Lisette formatter should preserve single-line interpolation in compatible cases, or
    • Formatter rules should be configured to avoid splitting interpolation argument expressions across lines.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /lisette, current file: none) bash-$

  2. Claude Assistant

    Now let's write a reproduction test before making changes.

  3. Claude Assistant

    Let's create a small test binary using cargo to reproduce the issue.

  4. Claude Assistant

    Reproduced the bug. Now let's confirm the compiler rejects this output.

  5. Claude Assistant

    Confirmed the reproduction matches the exact reported error. Now let's implement the fix in format_string.

  6. Claude Assistant

    Now need to add to_pretty_string import in scope (already accessible via Document since it's a method). Also need to import nothing extra since Document already imported. Let's build.

  7. Claude Assistant

    Now let's re-run the repro example.

  8. Claude Assistant

    The interpolation is preserved on a single line even though it exceeds 80 columns overall. Now let's verify this reformatted output round-trips through the lexer without errors.

  9. Claude Assistant

    Now let's test the exact example from the issue itself (with the trailing-comma multiline call already present in source) to see behavior — formatter should collapse it back to single line.

  10. Claude Assistant

    Let's revert the Cargo.toml dev-dependency addition since it was only needed for the example scripts, then run tests.

  11. Claude Assistant

    Now let's build the whole workspace and run tests.

  12. Claude Assistant

    Build succeeds. Now run test suites relevant to formatting.

  13. Claude Assistant

    Good — same failures exist before our change, so pre-existing/environment-related, not caused by us. Let's restore our change.

  14. Claude Assistant

    Good, now clean. Let's run just the format spec tests.

  15. Claude Assistant

    All 292 format tests pass. Let's also run the LSP formatting stress test mentioned, and any format-related tests in other crates.

  16. Claude Assistant

    Now let's run the fuzz seed corpus file (format_string.lis) through the formatter/lexer round-trip to double check nothing breaks with more complex nested cases.

  17. Claude Assistant

    All good — if x { 1 } else { 0 } interpolation remains single-line as expected. Clean up test artifacts.

  18. Claude Assistant

    Let's view the final diff.

  19. Claude Assistant

    Now let's run the full spec test suite for format, lex, parse, and lsp crates one more time comprehensively, plus fuzz target compile check (not running fuzz, just build) to be safe.

  20. Claude Assistant

    All confirmed clean and pre-existing failures are unrelated to formatting (they're all in spec::emit/spec::build, present identically before and after our change). Let's also add a quick focused check of spec::format tests once more in isolation to be safe.

  21. Claude Assistant

    All 292 pass cleanly in isolation. Final diff review:

  22. Claude Assistant

    This is a clean, minimal, targeted fix. Let's go through the checklist explicitly.

  23. Claude Assistant

    Summary

    Root cause: In crates/format/src/formatter/expression.rs, the format_string function rendered each f-string interpolation expression by simply calling self.expression(e) and embedding the resulting Document directly into the overall document tree, which is later pretty-printed with the module's global 80-column width limit. Because the Wadler-style Group breaking decision in this pretty-printer (lindig.rs) is based on the already-consumed column width at the point the group is reached (not on the interpolation expression's own local width), a long f-string prefix could push an otherwise-short call expression's Group fits-check over budget, causing the formatter to wrap call arguments across multiple lines — something the lexer explicitly forbids inside f"...{...}" interpolations (Multi-line f-string interpolation / format_string_multiline_interpolation).

    Fix: Added format_interpolation_expression, which renders the interpolation's expression document independently using Document::to_pretty_string with an effectively unbounded width (1_000_000 columns). This guarantees that width-driven breaking decisions for the interpolation expression are made in isolation, so any expression that could originally fit on a single source line (which the lexer already guarantees, since it rejects any interpolation containing real newlines) is now always re-emitted on a single line, regardless of how much text precedes it in the f-string or where it sits on the overall line.

    Checklist

    • Reproduced the reported error: Yes. I wrote a temporary example (crates/format/examples/repro.rs, removed before submitting) that formatted a single-line f-string call similar to the issue and confirmed the formatter previously rewrote it into a multi-line interpolation call, which the lexer then rejected with the exact Multi-line f-string interpolation / f-string interpolations must be single-line error from the issue.
    • Confirmed the fix resolves the error: Yes. After the change, the same input renders the interpolation call on a single line (even though the overall physical line exceeds 80 columns), and feeding the formatted output back through the lexer succeeds with no errors. I also verified the fix is idempotent (formatting the output again produces identical text).
    • Thought about edge cases: Considered: (1) interpolation expressions that themselves contain forced/verbatim newlines (defensively handled by falling back to Document::verbatim if the flattened rendering unexpectedly contains a newline); (2) nested constructs like if/else inside interpolations (verified via the existing format_string.lis fuzz seed corpus, output unchanged/still single-line); (3) multi-part f-strings with several interpolations and surrounding literal text with real newlines (verified existing format_fstring_multiline_text_roundtrip test still passes); (4) sources that are already invalid (contain real multi-line interpolations) — behavior unchanged, they are still rejected at the lexer stage before formatting, which is correct and unrelated to this fix.
    • Ran existing tests: Ran the full spec::format test suite (292 tests) — all pass. Also ran the LSP stress_format_string_interpolation_positions test — passes. Ran the full workspace test suite and confirmed the large number of failures in spec::emit/spec::build are pre-existing and identical in count (1588) both before and after this change (verified via git stash), so they are unrelated to this fix (environment/tooling issue, e.g. missing Go toolchain for codegen tests). Cleaned up all temporary example files and stray .snap.new artifacts before finishing.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.