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

[SR-12904] Add fix-it allowing unreasonable time for switch checking failing to check in "reasonable time" #55350

Open
haikusw opened this issue May 29, 2020 · 0 comments

Comments

@haikusw
Copy link
Contributor

haikusw commented May 29, 2020

Previous ID SR-12904
Radar None
Original Reporter @haikusw
Type Improvement

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement
Assignee None
Priority Medium

md5: abfcbf265d46a7b46c8eeaf39eb0b0fd

Issue Description:

When I get the error:

“The compiler is unable to check that this switch is exhaustive in reasonable time”

Sometimes I do not want to add a `default:` case.

So it would be nice if the possible "fix" choices included, “go ahead and use an ‘unreasonable’ amount of time please” and then when it figured out that the switch was not exhaustive it could prompt to fix by generating the missing cases (which can be laborious by hand).

Example use case: I have an enum with associated values of differing types and quite a few cases. I have to write my own operator == in order to make it Equatable. In that scenario I want the compiler to warn me if I add a new enum case and forget to add the comparison case for it in the switch statement in the == implementation.

What I'd like to do is have the compiler generate all the possible combinations for me given the current definition so that I can be explicit about returning false for those and avoid using default: which prevents the compiler from helping me if I forget to add a case to the operator == implementation.

In simpler situations the compiler will offer to do this but I guess in the one in question it took too long to do the checking, presented the error above, and I wasn't given the opportunity to have the compiler generate the lengthy all possible cases code for me.

TIA.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant