Open
Description
Description
No response
Reproduction
struct S {
init(i: Int) {}
}
var arrB: [S] = []
arrB.append(.init(x: ""))
test.swift:98:6: error: no exact matches in call to instance method 'append' [no_overloads_match_exactly_in_call]
arrB.append(.init(x: ""))
^
Swift.Array.append:2:33: note: incorrect labels for candidate (have: '(_:)', expected: '(contentsOf:)') [candidate_expected_different_labels]
@inlinable public mutating func append<S>(contentsOf newElements: __owned S) where Element == S.Element, S : Sequence}
^
Swift.RangeReplaceableCollection.append:2:33: note: incorrect labels for candidate (have: '(_:)', expected: '(contentsOf:)') [candidate_expected_different_labels]
@inlinable public mutating func append<S>(contentsOf newElements: __owned S) where S : Sequence, Self.Element == S.Element}
^
test.swift:98:14: error: 'Sequence' cannot be constructed because it has no accessible initializers [no_accessible_initializers]
arrB.append(.init(x: ""))
Expected behavior
This combination of issues is causing us to prefer the more abstract append(contentsOf:)
solution. I would expect it to carry more reasons to be disfavored due to the additional argument label mismatch and absence of a viable initializer.
Environment
Swift version 6.2-dev (LLVM c23e68dd0fa9228, Swift 278248e)
Additional information
No response