[SR-5952] Type checker rejects generic argument to Array.index(of:). #48511
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
Environment
$ swift --version
Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)
Target: x86_64-apple-macosx10.9
$ uname -v
Darwin Kernel Version 17.0.0: Thu Aug 24 22:01:05 PDT 2017; root:xnu-4570.1.46~3/RELEASE_X86_64
Additional Detail from JIRA
md5: 44b14015fe1600464d2f0f75bc651fcb
Issue Description:
Examples (sorry for the bad formatting but JIRA is misbehaving - I tried):
struct S<Element> {
var a: Array<Element>
func f(element: Element) {
_= a.index(of: element)
}
}
func g<T>(element: T, a: [T]) {
_= a.index(of: element)
}
Both of these examples give errors; I think they should compile!
tt.swift:5:11: error: cannot invoke 'index' with an argument list of type '(of: Element)'
_ = a.index(of: element)
^
tt.swift:5:11: note: expected an argument list of type '(of: Self.Element)'
_ = a.index(of: element)
^
tt.swift:10:9: error: cannot invoke 'index' with an argument list of type '(of: T)'
_ = a.index(of: element)
^
tt.swift:10:9: note: expected an argument list of type '(of: Self.Element)'
_ = a.index(of: element)
^
The text was updated successfully, but these errors were encountered: