I've extracted from TCA's #1086 the following minimal suite that doesn't pass when built in Release mode:
import CasePaths
import XCTest
public enum RootAction: Equatable {
case branch(BranchAction)
// case noop // Add this and extraction succeeds
}
public enum BranchAction: Equatable {
case firstAction(Bool)
case secondAction(Bool)
case leaf(LeafAction) // Remove this and extraction succeeds
}
public enum LeafAction: Equatable {
case value(Value) // Or case value(Any) with explicit `Equatable` conformance.
}
public struct Value: Equatable {
var value: Any
public static func == (lhs: Value, rhs: Value) -> Bool { true }
}
class CasePathIssueTests: XCTestCase {
func testFirst() throws {
XCTAssertEqual(
(/RootAction.branch).extract(from: .branch(.firstAction(true))),
.firstAction(true)
)
}
func testSecond() throws {
XCTAssertEqual(
(/RootAction.branch).extract(from: .branch(.secondAction(true))),
.secondAction(true)
)
}
}
A few comments:
- It passes in
Debug mode
- If
.firstAction has no associated value, it becomes the one that fails to extract, and second passes.
I'm not knowledgeable enough with runtime and the intricacies of the extraction algorithm to fix this issue.
Originally posted by @tgrapperon in pointfreeco/swift-case-paths#71