Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunctionDeclSyntax does not expand body #2880

Open
zzyptr opened this issue Oct 11, 2024 · 3 comments
Open

FunctionDeclSyntax does not expand body #2880

zzyptr opened this issue Oct 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@zzyptr
Copy link

zzyptr commented Oct 11, 2024

Description

FunctionDeclSyntax does not expand body as expected.

let functionDeclaration = FunctionDeclSyntax(
    name: .identifier("foo"),
    signature: FunctionSignatureSyntax(parameterClause: FunctionParameterClauseSyntax(parameters: [])),
    body: CodeBlockSyntax(statements: [])
)

will expand to

func foo() 

no body

Steps to Reproduce

No response

@zzyptr zzyptr added the bug Something isn't working label Oct 11, 2024
@ahoppen
Copy link
Member

ahoppen commented Oct 11, 2024

Synced to Apple’s issue tracker as rdar://137723591

@ahoppen
Copy link
Member

ahoppen commented Oct 14, 2024

I was unable to reproduce the issue.

let functionDeclaration = FunctionDeclSyntax(
  name: .identifier("foo"),
  signature: FunctionSignatureSyntax(parameterClause: FunctionParameterClauseSyntax(parameters: [])),
  body: CodeBlockSyntax(statements: [])
)
print(functionDeclaration.formatted())

prints

func foo() {
}

Which contains a body.

Are you doing anything differently? If so, can you share a reproducing project?

@zzyptr
Copy link
Author

zzyptr commented Oct 15, 2024

I am sorry. I found the body of the function was removed by a body macro that with a implementation of return []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants