[SR-13234] Overload resolution with autoclosure and tuple labels (Swift 5.3 regression) #55674
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
regression
swift 5.3
type checker
Area → compiler: Semantic analysis
Attachment: Download
Environment
Xcode 12.0 beta 2 (Apple Swift version 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)).
The code does compile in Xcode 11.6 and previous versions.
Additional Detail from JIRA
md5: 4e8ff947e165718b87a487f24f10b4fd
Issue Description:
The following code doesn't compile in Swift 5.3 (Xcode 12.0 beta 2), but does compile in Swift 5.2:
The compile error in the
eqElements(actual, expected)
line is:I suspect this is what happens:
[(label: 1, true)]
somehow causes the compiler to choose the first overload ofeqElements
, which requires the array elements to be Equatable. I'd expect the second overload to be chosen, which doesn't have this requirement.[(label: 1, true)]
with[(1, true)]
in both lines, the code compiles and correctly chooses the second overload.@autoclosure
parameters to normal parameters (e.g. replace@autoclosure () -> S1
withS1
etc.), I can keep the tuple element label and the code still compiles and chooses the second overload.The combination of
@autoclosure
and the tuple element label seems to trigger the change in behavior.The text was updated successfully, but these errors were encountered: