Open
Description
Description
I'm using version 600.0.1
and wrote this code as part of a macro expression:
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:
"Some Text "
But I expect it to be:
"Some Text"
Am I missing something?
Steps to Reproduce
Here's a more complete code example:
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)
}
}