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

[SR-7117] Infinite Recursion in BinaryInteger between < and distance(to:) #49665

Open
swift-ci opened this issue Mar 4, 2018 · 3 comments
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 4, 2018

Previous ID SR-7117
Radar None
Original Reporter CTMacUser (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 9.3beta

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @moiseev
Priority Medium

md5: 1bdd075b2d5976ac4986e66fe87b489a

Issue Description:

As of the current versions of Strideable and BinaryInteger:

BinaryInteger's default implementation of homogenous < is taken from Strideable, in which it calls distance. BinaryInteger's default implementation of distance calls < and >. So there's infinite recursion.

I guess < (and probably ==) need to be reimplemented without distance.

@belkadan
Copy link
Contributor

belkadan commented Mar 5, 2018

cc @moiseev

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 6, 2018

Comment by Daryle Walker (JIRA)

I've attached sample code (ComparisonViaWords.swift) for implementing == and < using the words properties. It may even be adaptable to heterogeneous arguments, since all BinaryInteger types have to use the same element type and sequence format for words.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 6, 2018

Comment by Daryle Walker (JIRA)

It seems I may have forgotten a

private enum Order { case less, equal, greater }

For compareLess, but outside the extension's definition. (I wanted the enum to be within the method, but that's not allowed for generics.)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants