tvOSBrowser icon indicating copy to clipboard operation
tvOSBrowser copied to clipboard

I've extracted from TCA's [#1086](https://github.com/pointfreeco/swift-composable-architecture/issues/1086) the following minimal suite that doesn't pass when built in `Release` mode:

Open Yynny opened this issue 3 years ago • 0 comments

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 https://github.com/pointfreeco/swift-case-paths/issues/71

Yynny avatar Aug 31 '22 02:08 Yynny