Skip to content

[pull] main from swiftlang:main#808

Merged
pull[bot] merged 1 commit into
kkebo:mainfrom
swiftlang:main
May 25, 2026
Merged

[pull] main from swiftlang:main#808
pull[bot] merged 1 commit into
kkebo:mainfrom
swiftlang:main

Conversation

@pull

@pull pull Bot commented May 25, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

#1210)

An assertion failure ("Too many unresolved delimiter token lengths") was
triggered whenever a `// swift-format-ignore` directive was applied to the
last element of a conditional-compilation clause, e.g.:

    #if FOO
    // swift-format-ignore
    print("Hi")
    #endif

The `IfConfigClause` visitor attaches its closing `.open`/`.close` group via
`after(node.elements?.lastToken, ...)`. When that last element is
formatter-ignored, its entire subtree is emitted as a single verbatim token
and none of its tokens are visited, so the `after` group is dropped and the
`.open` is left unclosed. The pretty printer then finds the delimiter stack
unbalanced and trips the assertion (release builds would mis-resolve token
lengths).

Detect when the body's last token belongs to a formatter-ignored item and, in
that case, attach the closing tokens before the following token (the next
`#elseif`/`#else`/`#endif`), which is always visited. This mirrors the existing
empty-clause branch and the analogous handling in the `SwitchCase` visitor.
Non-ignored `#if` blocks are unaffected.
@pull pull Bot locked and limited conversation to collaborators May 25, 2026
@pull pull Bot added the ⤵️ pull label May 25, 2026
@pull pull Bot assigned kkebo May 25, 2026
@pull pull Bot requested a review from kkebo May 25, 2026 23:10
@pull pull Bot merged commit 40aef03 into kkebo:main May 25, 2026
30 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants