Use lowerCamelCase for @warn_unqualified_access attribute?

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

<Library Evolution Support in Swift (“Resilience”) — Swift 3.0 documentation;

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

<swift/SequenceAlgorithms.swift.gyb at 0661f6157852a0478f3b3851eb95586849e98cf8 · apple/swift · GitHub;

<swift/ImportDecl.cpp at 84cd5cc04cd3a8fd920cbc6d831fbc398cc1e8ea · apple/swift · GitHub;

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

<swift/Attr.def at 173658a5d871cd45398e9653078dac461748f13a · apple/swift · GitHub;

-- Ben

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

These were not meant to be public.

Doug

1 Like

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?

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.

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

1 Like

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

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

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.

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

1 Like