Skip to content

Work around a bug in the older Swift compiler used to build swift-syntax in the toolchain, which affected certain result builder APIs #541

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

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ extension FunctionParameterSyntax {
// Enclose the base type declaration reference in a 1-element tuple, e.g.
// `(<baseType>)`. It will be used in a member access expression below, and
// some types (such as function types) require this.
let metatypeMemberAccessBase = TupleExprSyntax {
LabeledExprListSyntax {
LabeledExprSyntax(expression: baseTypeDeclReferenceExpr)
}
}
//
// Intentionally avoid using the result builder variant of these APIs due to
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a swift-syntax or swift PR/issue you can point to here? For future reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nobody involved in the investigation was sure what exactly the problem was, but in any event, the bug itself has long been fixed. We believe it was fixed in Swift 5.10. The problem is Swift's CI, in this case at least, is building some early dependencies using Swift 5.9 or earlier (intentionally), and that compiler had the bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alrighty. And the bug only affected this use of a result builder? How strange!

// a bug which affected a range of Swift compilers (including the one
// currently used to build swift-syntax in the toolchain) and caused one of
// these APIs to have an incorrect representation in the module interface.
let metatypeMemberAccessBase = TupleExprSyntax(elements: [LabeledExprSyntax(expression: baseTypeDeclReferenceExpr)])

return MemberAccessExprSyntax(base: metatypeMemberAccessBase, name: .identifier("self"))
}
Expand Down