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

DiagnosticSeverity should conform to Equatable #2964

Closed
grynspan opened this issue Feb 11, 2025 · 4 comments · Fixed by #2965
Closed

DiagnosticSeverity should conform to Equatable #2964

grynspan opened this issue Feb 11, 2025 · 4 comments · Fixed by #2965
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@grynspan
Copy link
Contributor

Description

DiagnosticSeverity has a clearly-defined ranking and should conform to Comparable.

It would make it easier for macro code to e.g. suppress its own warnings (with something like diagnostics.filter { $0.severity >= .error }) or enforce -Werror-like semantics, that sort of thing.

@grynspan grynspan added the enhancement New feature or request label Feb 11, 2025
@ahoppen
Copy link
Member

ahoppen commented Feb 11, 2025

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

@ahoppen ahoppen added the good first issue Good for newcomers label Feb 12, 2025
@ahoppen
Copy link
Member

ahoppen commented Feb 12, 2025

I disagree that DiagnosticSeverity has a clearly defined ranking. error is obviously more severe than warning but there isn’t really a clear ranking between remark and note, they are just different kinds of diagnostics. I thus don’t think that DiagnosticSeverity should be Comparable. Also, if you want to suppress warnings, checking for == .warning or == .error should work equally well as >= .someSeverityLevel.

@ahoppen ahoppen closed this as completed Feb 12, 2025
@grynspan
Copy link
Contributor Author

It doesn't conform to Equatable either, FWIW.

@grynspan grynspan reopened this Feb 12, 2025
ahoppen added a commit to ahoppen/swift-syntax that referenced this issue Feb 14, 2025
ahoppen added a commit to ahoppen/swift-syntax that referenced this issue Feb 14, 2025
@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2025

Good point, adding there Equatable conformance here: #2965

@grynspan grynspan changed the title DiagnosticSeverity should conform to Comparable DiagnosticSeverity should conform to ~~Comparable~~ Equatable Feb 14, 2025
@grynspan grynspan changed the title DiagnosticSeverity should conform to ~~Comparable~~ Equatable DiagnosticSeverity should conform to Equatable Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants