Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Formatter rewrites Lisette f-strings to multiline interpolation that the compiler…

  1. User

    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.

  2. Assistant

    The fix works — the interpolation stays single-line and formatting is idempotent. Accept the new snapshot:

  3. Assistant

    Confirmed pre-existing (gofmt missing in this environment — Go output comes back unformatted). Clean up the stray .snap.new files and run the full format suite:

  4. Assistant

    I'll add spec tests for those edge cases directly:

  5. Assistant

    Both render correctly single-line (the idempotency assertion passed; only the snapshots were new). Accept them:

  6. Assistant

    That system note reflects the stash I just ran (baseline state). Let me get the baseline failure list and restore my changes:

  7. Assistant

    Fixed. The formatter no longer splits f-string interpolations across lines.

    Root cause

    The lexer hard-rejects newlines inside f"...{...}" interpolations (crates/syntax/src/lex/mod.rs:998), but the formatter's format_string embedded each interpolation expression's document — including all its groups and break points — directly into the output. When the line exceeded MAX_LINE_WIDTH (80), the call's argument group broke across lines, producing output the compiler then rejects.

    Changes

    • crates/format/src/lindig.rs — added Document::to_flat_string(), which renders a document on a single line: every strict/flex break uses its unbroken form, group fitting and force_break are ignored, and Newline becomes a space.
    • crates/format/src/formatter/expression.rs:239 — format_string now renders each interpolation expression via to_flat_string() instead of embedding its breakable document, so interpolations can never be split regardless of line width. This is always safe: valid input interpolations are single-line by the lexer's rule, so a flat rendering exists for anything that parses.
    • tests/spec/format/mod.rs — three regression tests (+ snapshots): the reported case (long method call in interpolation), a nested call with a slice literal, and a lambda argument. All previously either failed re-lexing after format or would break at width 80; all now stay single-line and format idempotently.

    Verification

    • The reported case reproduced before the fix: formatting produced multiline interpolation whose re-lex failed with Multi-line f-string interpolation.
    • All 295 spec::format tests pass, including idempotency assertions.
    • Full suite failure sets are byte-identical before and after the change (the 1588 pre-existing failures are spec::build/spec::emit tests needing a Go toolchain absent in this environment).
    • cargo clippy and cargo fmt --check are clean.

    One trade-off to note: an interpolation rendered flat can push a line past the 80-column limit, but that's the only compilable output — the alternative the lexer suggests (extracting to a let binding) is a semantic rewrite the formatter shouldn't do on its own.

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