Cannot witness a subscript with a typed error #78379
Labels
accessors
Feature → declarations: Variable (property) accessors
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
conformances
Feature → protocol: protocol conformances
declarations
Feature: declarations
swift 6.1
throws & rethrows
Feature → error handling: throws & rethrows
type checker
Area → compiler: Semantic analysis
typed throws
Feature → error handling → throws & rethrows: Typed throws
unexpected error
Bug: Unexpected error
Description
A protocol containing a
subscript
requirement with aget throws(…)
accessor cannot be implemented. The compiler diagnoses a “Type ‘X’ does not conform to protocol ‘Y’” error, even if the implementingsubscript
provides the exact same accessor as in the requirement.Reproduction
Expected behavior
Preferably, the compiler should accept the implementing accessor as a suitable witness for the requirement.
Alternatively, the compiler should report that subscript accessor requirements cannot use typed errors (and use untyped errors instead).
Environment
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Additional information
Typed throws were proposed in SE-0413.
The text was updated successfully, but these errors were encountered: