[pull] main from swiftlang:main#808
Merged
Merged
Conversation
#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : )