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-1798] stride(from:to:by) doesn't compile in an Int extension in Xcode 8 beta 1 #44407

Closed
swift-ci opened this issue Jun 17, 2016 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1798
Radar rdar://problem/26863028
Original Reporter salmanjamil (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 8 beta 1, Swift 3, Mac OS X El-Capitan

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 7ccfe25e1e224104aa04838e62edd4b7

Issue Description:

The Swift 3.0 compiler reports an error in Xcode 8 beta 1 when we try to create a StrideTo<Int> using stride(from:to:by) in an extension of Int. The function seems to work fine at other places but in an Int extension it doesn't compile. The function compiles successfully in the extension if we prefix it with Swift i.e using Swift.stride(from:to:by) works fine.

@belkadan
Copy link
Contributor

@moiseev, is this because there's now a stride member on Int itself?

@moiseev
Copy link
Mannequin

moiseev mannequin commented Jun 20, 2016

@belkadan Most likely it's the unavailable old `stride` method in an extension to `Strideable`. The same situation as with `min` and `max` inside a `Collection` extension. You have to fully qualify it, even though the type of the function is different.

@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2016

Hm, should we add @warn_unqualified_access here?

@moiseev
Copy link
Mannequin

moiseev mannequin commented Jul 5, 2016

No, because it is only a problem when you are inside the extension to Int.

@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2016

Right, the point of the attribute is that you put it on a member you don't want to call unqualified, which only happens inside extensions (and types newly adopting Strideable, I guess).

@moiseev
Copy link
Mannequin

moiseev mannequin commented Jul 6, 2016

Oh nice. Thanks, Jordan.

@moiseev
Copy link
Mannequin

moiseev mannequin commented Jul 6, 2016

#3349

@DougGregor
Copy link
Member

error: Factorial.playground:14:11: error: use of 'stride' nearly matches global function 'stride(from:to:by🙂' in module 'Swift' rather than instance method 'stride(to:by🙂'
let s = stride(from: self, to: 1, by: -1) // stride(from:to:by) doesn't work in an extension
^

Factorial.playground:14:11: note: use 'Swift.' to reference the global function in module 'Swift'
let s = stride(from: self, to: 1, by: -1) // stride(from:to:by) doesn't work in an extension
^
Swift.

and, barring a change to the language (which would go through swift-evolution rather than Jira), this is the best we’ll get.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants