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-4170] Swift 3.1 compiler generates warning of some global functions #46753

Open
swift-ci opened this issue Mar 6, 2017 · 3 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 6, 2017

Previous ID SR-4170
Radar None
Original Reporter Okui (JIRA User)
Type Bug
Environment

Xcode-Beta Version 8.3 beta 2 (8W120l) with Apple Swift version 3.1 (swiftlang-802.0.31.3 clang-802.0.30.2) Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression
Assignee None
Priority Medium

md5: 3cac9218e5de50771ca63ae2bcdce774

Issue Description:

In particular case, Swift 3.1 compiler generates warning of global math function like this:

abs.swift:4:12: warning: 'abs' is deprecated: Please use the `abs(_:)` free function

Entire code is like this:

abs.swift

extension Double {

  func myAbsolute(value : Double) -> Double {
    return abs(value)
  }

  static func myStaticAbsolute(value : Double) -> Double {
    return abs(value)
  }

}

func myAbsolute(value: Double) -> Double {
  return abs(value)
}

First function (non-static one) does not produce any warning but second one (static one) does produce the warning. The last function (defined in global space) dose not produce any warnings.

The code can be compiled without any warning prior to swift 3.1.

@belkadan
Copy link
Contributor

belkadan commented Mar 6, 2017

The second function is resolving to the type method Double.abs, not the top-level function Swift.abs. You can explicitly write Swift.abs to work around this.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 6, 2017

Comment by Kaz Okui (JIRA)

Huh![]( I tried using Swift.abs and still got warning while ago... but must be resolved at some point?? Anyway, it worked)

@swift-ci
Copy link
Collaborator Author

Comment by Sihao Lu (JIRA)

Okui (JIRA User) I tried `Swift.abs` without warning.

@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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants