You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Motivation
Today, there are three sets of arguments for (the long form of)
@available
:*
,swift
, or an actual platform name)deprecated
andunavailable
message
andrenamed
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
The text was updated successfully, but these errors were encountered: