Skip to content

Add @unknown default to switch over RawSameTypeRequirementSyntax.LeftType#3331

Open
nesium wants to merge 1 commit into
swiftlang:mainfrom
nesium:parser/exhaustive-switch-on-LeftType
Open

Add @unknown default to switch over RawSameTypeRequirementSyntax.LeftType#3331
nesium wants to merge 1 commit into
swiftlang:mainfrom
nesium:parser/exhaustive-switch-on-LeftType

Conversation

@nesium

@nesium nesium commented May 14, 2026

Copy link
Copy Markdown

Hello!

The switch over firstArgument in parseGenericWhereClauseRequirements (around Sources/SwiftParser/Declarations.swift:766) only handles .expr and .type. RawSameTypeRequirementSyntax.LeftType is a public enum that isn't @frozen, so consumers building swift-syntax with BUILD_LIBRARY_FOR_DISTRIBUTION=YES hit:

error: switch covers known cases, but 'RawSameTypeRequirementSyntax.LeftType' may have additional unknown values

The same situation was already addressed across the codebase in eee827f by wrapping such switches in #if RESILIENT_LIBRARIES @unknown default: fatalError() #endif. This switch was added later and is missing the clause, so the PR just brings it in line.

I ran into this while archiving an XCFramework that links a .macro target depending on swift-syntax.

…Type

The switch over `firstArgument` in `parseGenericWhereClauseRequirements`
(Sources/SwiftParser/Declarations.swift) only handles `.expr` and `.type`.
`RawSameTypeRequirementSyntax.LeftType` is a public enum that isn't `@frozen`,
so consumers building swift-syntax with `BUILD_LIBRARY_FOR_DISTRIBUTION=YES`
hit a compile error here. Wrap the switch with the
`#if RESILIENT_LIBRARIES @unknown default: fatalError() #endif` clause that
was established for this exact situation in eee827f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant