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.


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



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


-- 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.


(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.