Use lowerCamelCase for @warn_unqualified_access attribute?


(Ben Rimmington) #1

I noticed that the @warn_unqualified_access attribute in LibraryEvolution hasn't been updated to lowerCamelCase.

<http://jrose-apple.github.io/swift-library-evolution/#methods>

It's currently used by the `min` and `max` methods of Sequence, and the `print` methods in AppKit.

<https://github.com/apple/swift/blob/0661f61/stdlib/public/core/SequenceAlgorithms.swift.gyb#L150-L166>

<https://github.com/apple/swift/blob/84cd5cc/lib/ClangImporter/ImportDecl.cpp#L6463-L6476>

It doesn't have the UserInaccessible option, so can @warn_unqualified_access also be used in client code?

<https://github.com/apple/swift/blob/173658a/include/swift/AST/Attr.def#L246-L247>

-- Ben


(Ben Rimmington) #2

The requires_stored_property_inits and warn_unqualified_access attributes were recently added to The Swift Programming Language book (for Swift 4.2).

Are these attributes meant to be public? They haven't gone through Swift evolution AFAIK.

Cc: @Douglas_Gregor, @jrose


(Douglas Gregor) #3

These were not meant to be public.

Doug


(Ben Rimmington) #4

I've created SR-8892 for updating the book.

Should requires_stored_property_inits and warn_unqualified_access also be made UserInaccessible in AST/Attr.def?


(Kyle Murray) #5

These attributes can show up in arbitrary API documentation (like Sequence.min()) because they're not underscored. As a result, people reading API documentation might encounter them, so we added information about them to the attributes reference.

They predate SE-0001, so that makes sense.

I don't think it makes sense to change how they're documented until something about their implementation changes; whether that means prefixing them with an underscore, adding them to Attr.def, or Swift Evolution-ing them to camel case.


(Ben Rimmington) #6

@krilnon If these attributes are documented, it may give the impression that they are safe to use in third-party APIs. Could you at least add a disclaimer that they are currently for internal use only?

I can look into prefixing them with an underscore, if their originators @Douglas_Gregor and @jrose agree.


(Jordan Rose) #7

That would be source-breaking. I can't see why anyone would want requires_stored_property_inits, but warn_unqualified_access seems perfectly reasonable.


(Erik Little) #8

We have precedent for renaming modifiers that weren’t meant to be public. See @effects to @_effects


(Jordan Rose) #9

Yes, but _effects is incredibly unsafe (in the undefined-behavior-if-it's-wrong sense). warn_unqualified_access is something that people could reasonably be correctly using.


(Ben Rimmington) #10

@jrose Could @warn_unqualified_access be made into an alias for @warnUnqualifiedAccess?

Similar to SE-0106 (with SR-1823 and SR-1887 in progress) for macOS and its OSX alias.

See also apple/swift#12674.