-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Embedded] Diagnose untyped throws as an Embedded Swift restriction #84283
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
DougGregor
merged 2 commits into
swiftlang:main
from
DougGregor:embedded-swift-untyped-throws-restriction
Sep 15, 2025
Merged
[Embedded] Diagnose untyped throws as an Embedded Swift restriction #84283
DougGregor
merged 2 commits into
swiftlang:main
from
DougGregor:embedded-swift-untyped-throws-restriction
Sep 15, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
@swift-ci please smoke test Windows |
Untyped throws depends on existentials (`any Error`), and is therefore not available in Embedded Swift. Introduce a diagnostic that diagnoses any use of untyped throws, suggesting that one use typed throws instead. Make this an opt-in diagnostic enabled with `-Wwarning EmbeddedRestrictions`, whether in Embedded Swift or not, using the "default ignore" flag on these new warnings. Document this new diagnostic group, and put the existing Embedded Swift error about weak/unowned references in it as well. Part of the general push to have the type checker identify code that will not compile as Embedded Swift earlier, rdar://133874555.
edf7f36
to
95d3550
Compare
@swift-ci please smoke test |
@swift-ci please clean smoke test |
…led as Embedded When emitting diagnostics for the Embedded Swift restrictions outside of Embedded Swift mode, consider `#if $Embedded` and `#if hasFeature(Embedded)` configurations. If the code where we would emit the diagnostic would be disabled in Embedded Swift by one of those checks, don't emit the diagnostic. This helps code that can compile either with Embedded or regular Swift stay within the restrictions on Embedded Swift.
72bb532
to
865c643
Compare
@swift-ci please smoke test |
Note: this specific thing was also tracked by rdar://121205043, silly me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Untyped throws depends on existentials (
any Error
), and is therefore not available in Embedded Swift. Introduce a diagnostic that diagnoses any use of untyped throws, suggesting that one use typed throws instead.Make this an opt-in diagnostic enabled with
-Wwarning EmbeddedRestrictions
, whether in Embedded Swift or not, using the "default ignore" flag on these new warnings. Document this new diagnostic group, and put the existing Embedded Swift error about weak/unowned references in it as well.When this diagnostic is enabled but we aren't in Embedded Swift, check for compiler conditionals like
#if hasFeature(Embedded)
and suppress the diagnostic if the code we're checking will not be compiled when building as Embedded Swift. For example, if it's in a#if !hasFeature(Embedded)
block.Part of the general push to have the type checker identify code that will not compile as Embedded Swift earlier, rdar://133874555.