swiftlang / swiftlang/swift-syntax
StringLiteralExprSyntax adds whitespace in front of closingQuote
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 553
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 16
Description
### Description
I'm using version `600.0.1` and wrote this code as part of a macro expression:
```swift
let defaultValueLiteral = StringLiteralExprSyntax(
openingQuote: .stringQuoteToken(),
segments: StringLiteralSegmentListSyntax([.stringSegment(.init(content: "Some Text"))]),
closingQuote: .stringQuoteToken()
)
```
When I return it in my `ExpressionMacro` wrapped into an `ExprSyntax`, the expanded code looks like this:
```swift
"Some Text "
```
But I expect it to be:
```swift
"Some Text"
```
Am I missing something?
### Steps to Reproduce
Here's a more complete code example:
```swift
public struct TranslationKey: ExpressionMacro {
public static func expansion(
of node: some FreestandingMacroExpansionSyntax,
in context: some MacroExpansionContext
) throws -> ExprSyntax {
// constructing: `"Some Text"`
let defaultValueLiteral = StringLiteralExprSyntax(
openingQuote: .stringQuoteToken(),
segments: StringLiteralSegmentListSyntax([.stringSegment(.init(content: "Some Text"))]),
closingQuote: .stringQuoteToken()
)
// I have actually more code here (just in case you were wondering)
return ExprSyntax(defaultValueLiteral)
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.