Skip to content

Conversation

@jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Nov 7, 2025

Previously we would crash (at runtime) on this pattern:

let x: Never switch x {}

This appears to be due to the fact that the switch over the uninhabited value did not result in any instructions DI considers a use being produced. This change adds special handling of this case so that we now emit a load of the value so DI correctly diagnoses the use before init.

Resolves: #74478

@jamieQ
Copy link
Contributor Author

jamieQ commented Nov 7, 2025

@swift-ci smoke test macos

@jamieQ
Copy link
Contributor Author

jamieQ commented Nov 7, 2025

@swift-ci please test source compatibility

…e cases Previously we would crash on this pattern: ```swift let x: Never switch x {} ``` This appears to be due to the fact that the switch over the uninhabited value did not result in any instructions DI considers a use being produced. This change adds special handling of this case so that we now emit a load of the value so DI correctly diagnoses the use before init.
@jamieQ
Copy link
Contributor Author

jamieQ commented Nov 8, 2025

@swift-ci please test

@jamieQ jamieQ marked this pull request as ready for review November 8, 2025 13:07
// Failure to do this in the past resulted in this bug:
// https://github.com/swiftlang/swift/issues/74478.

emitLoadOfLValue(E, std::move(lv), SGFContext::AllowImmediatePlusZero);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could someone verify if it matters what SGFContext value is used here? i assume this case should always result in a downstream error so i'm inclined to think it doesn't...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant