[SR-12131] Keypaths with the wrong base type yield misleading errors #54566
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
type checker
Area → compiler: Semantic analysis
Attachment: Download
Environment
Swift 5.1.3
Xcode 11.3 (11C29)
macOS Catalina 10.15.3
Additional Detail from JIRA
md5: 240a2a33b45480de1db96f07b198f1f1
Issue Description:
Trying to use the `[keyPath:]` subscript with a keypath with an incorrect base type doesn't yield an error telling you that, instead telling you the value has no subscripts (when getting) or that you cannot assign through the subscript because the value is immutable (when setting).
Consider the following snippet:
The first two methods compile just fine, but the second two yield those misleading errors I mentioned (screenshot attached).
The text was updated successfully, but these errors were encountered: