Skip to content

Fix extended string delimiter selection in renderLiteral#898

Merged
kukushechkin merged 1 commit into
apple:mainfrom
kukushechkin:fix-string-delimiter-handling-in-renderLiteral
Apr 24, 2026
Merged

Fix extended string delimiter selection in renderLiteral#898
kukushechkin merged 1 commit into
apple:mainfrom
kukushechkin:fix-string-delimiter-handling-in-renderLiteral

Conversation

@kukushechkin
Copy link
Copy Markdown
Contributor

Dynamically pick the minimum number of # delimiters so that neither the closing sequence nor the escape prefix appears in the content.

Motivation

When the string content contains "# or \#, a single-hash raw literal (#"..."#) produces unexpected Swift code.

Modifications

  • Dynamically pick the minimum number of # delimiters so that neither the closing sequence nor the escape prefix appears in the content.
  • Add test verifying correct handling of string delimiters.

Result

No unexpected Swift code is generated.

Test Plan

Unit tests.

When the string content contains `"#` or `\#`, a single-hash raw literal
  (`#"..."#`) produces unexpected Swift code. Dynamically pick the minimum number
  of `#` delimiters so that neither the closing sequence nor the escape
  prefix appears in the content.
@kukushechkin kukushechkin force-pushed the fix-string-delimiter-handling-in-renderLiteral branch from b230378 to c4a43f0 Compare April 20, 2026 13:16
Copy link
Copy Markdown
Collaborator

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kukushechkin!

@kukushechkin kukushechkin merged commit 83e8301 into apple:main Apr 24, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants