Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IdentifiedArray.replaceSubrange causes a stack overflow #125

Closed
peterkovacs opened this issue May 22, 2020 · 1 comment
Closed

IdentifiedArray.replaceSubrange causes a stack overflow #125

peterkovacs opened this issue May 22, 2020 · 1 comment

Comments

@peterkovacs
Copy link
Contributor

Describe the bug
Calling replaceSubrange on an identified array causes a stack overflow.

To Reproduce

  func testReplaceSubrange() {
    struct User: Equatable, Identifiable {
      let id: Int
      var name: String
    }

    var array: IdentifiedArray = [
      User(id: 3, name: "Blob Sr."),
      User(id: 2, name: "Blob Jr."),
      User(id: 1, name: "Blob"),
    ]

    array.replaceSubrange(0...1, with: [
      User(id: 4, name: "Flob IV"),
      User(id: 5, name: "Flob V")
    ])

    XCTAssertEqual(
      array,
      [User(id: 4, name: "Flob IV"), User(id: 5, name: "Flob V"), User(id: 1, name: "Blob")]
    )
  }

This results in repeated calls to

#69778	0x0000000111c933ed in protocol witness for RangeReplaceableCollection.replaceSubrange<A>(_:with:) in conformance <> IdentifiedArray<A, B> ()
#69779	0x00007fff5116a0f7 in RangeReplaceableCollection.replaceSubrange<A, B>(_:with:) ()

Environment

  • Xcode 11.5
  • Swift 5.2.4
@stephencelis
Copy link
Member

Fixed by #126.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants