Key path formed to setter with unavailable key path is writable #72809
Labels
availability
The @available attribute and availability checking in general
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
key paths
Feature: key paths (both native and Objective-C)
type checker
Area → compiler: Semantic analysis
Description
(First posted to the forums.)
Currently, a key path formed to a property that has an unavailable setter are WritableKeyPaths. This seems like a bug, since it allows code like dynamic member lookup to quietly compile what should crash at runtime.
While tracking the availability itself in the key path seems like a good idea and would allow library users to surface their own error messaging, I imagine that is a complex project to take on. Maybe as a baby step, key paths should at the very least be simply non-writable KeyPaths when the setter is unavailable.
Reproduction
Expected behavior
The key path returned should be
KeyPath
, notWritableKeyPath
, so the above should not compile.Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: