Skip to content

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: #32

@Yynny

Description

@Yynny

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions