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

Warn on @available(*, message: "abc") #78088

Open
jrose-signal opened this issue Dec 10, 2024 · 0 comments
Open

Warn on @available(*, message: "abc") #78088

jrose-signal opened this issue Dec 10, 2024 · 0 comments
Labels
feature A feature request or implementation triage needed This issue needs more specific labels

Comments

@jrose-signal
Copy link

Motivation

Today, there are three sets of arguments for (the long form of) @available:

  • The "platforms" (*, swift, or an actual platform name)
  • The "conditions": version ranges, as well as the plain deprecated and unavailable
  • Optional additional diagnostic context, message and renamed

The compiler enforces that the first is present and that it's not the only attribute, but it allows a platform and a diagnostic argument with no conditions, which can mislead people into thinking @available(*, message: "abc") or @available(*, renamed: "abc") will do something.

Proposed solution

Warn if @available has no conditions listed, as it does if there are neither conditions nor context arguments. It doesn't have to be an error, there's still a reasonable interpretation, but it is an easy mistake to make, especially if you're new to the attribute.

Alternatives considered

No response

Additional information

No response

@jrose-signal jrose-signal added feature A feature request or implementation triage needed This issue needs more specific labels labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant