Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Global constant strings generated by nested macros cannot be written to binary files. #79235

Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels
@Asura19

Description

@Asura19

Description

I use macro to create global constant string, it success.
But, when I use a nested macro to wrap#flat macro, it build success and expand as expected in XCode, but the constant string did not appears in mach-o file. (I usedXMachOViewer to check executable binary file)

ImageImage

Reproduction

Attached is a reduced package that reproduces the behavior:
Test.zip

publicstructFlatMacro:DeclarationMacro{publicstaticfunc expansion(        of node:someSwiftSyntax.FreestandingMacroExpansionSyntax,        in context:someSwiftSyntaxMacros.MacroExpansionContext)throws->[DeclSyntax]{letargumentList= node.argumentsvarname:String=""forargumentin argumentList{switch argument.label?.text{case"name":iflet stringLiteral= argument.expression.as(StringLiteralExprSyntax.self),let hostValue= stringLiteral.segments.first?.as(StringSegmentSyntax.self)?.content.text{                    name= hostValue}default:break}}letvarName="\(context.makeUniqueName("flat"))"letdeclarationString="""            let\(varName) ="~~~~\(name)""""return[DeclSyntax(stringLiteral: declarationString)]}}publicstructNestedMacro:DeclarationMacro{publicstaticfunc expansion(        of node:someSwiftSyntax.FreestandingMacroExpansionSyntax,        in context:someSwiftSyntaxMacros.MacroExpansionContext)throws->[DeclSyntax]{return["""          #flat(name:"456")"""]}}

Expected behavior

The global constant "~~~~456" will be compiled to the mach-o binary file.

Environment

swift 6.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp