Skip to content

[CS] Add contextual Bool type to switch-case where clause #63747

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 3 commits into from
Feb 18, 2023

Conversation

hamishknight
Copy link
Contributor

Seems this was accidentally omitted, which would crash in CSApply for any non-Bool-convertible type.

Resolves #63746

func issue63746() {
let fn = {
switch 0 {
case 1 where 0: // expected-error {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As an aside, this fix-it is useless for literals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh yeah, filed #63753

All but one client wants to set this to anything
other than `FreeTypeVariableBinding::Disallow`.
Seems this was accidentally omitted, which would
crash in CSApply for any non-Bool-convertible type.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit c82189d into swiftlang:main Feb 18, 2023
@hamishknight hamishknight deleted the oh-bool branch February 20, 2023 12:54
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.

Bad type conversion for switch-case where clause crashes compiler
3 participants