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-4185] Swift 3.1: Static property on String breaks string interpolation #46768

Open
swift-ci opened this issue Mar 7, 2017 · 4 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 7, 2017

Previous ID SR-4185
Radar rdar://problem/30885036
Original Reporter davidp_navdy (JIRA User)
Type Bug
Environment

Xcode: Version 8.2.1 (8C1002)
macOS: 10.12.3 (16D32)
For Swift 3.1, used the 3.1 Snapshot dated March 6, 2017.

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

md5: 02059bb474a34b9252238bb3a65f304b

Issue Description:

The following code compiles using Swift 3.0.2/Xcode 8.2; it reports an error using Xcode 8.3 beta 3 and the latest Swift 3.1 snapshot:

import Foundation

extension String {
    static let foo = "bar"
}

print("foo: \(.foo)")

Before and after:

$ xcrun swiftc --version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
$ xcrun swiftc StringStaticExtension.swift # no error
$ xcrun --toolchain swift swiftc --version
Apple Swift version 3.1-dev (LLVM a7c680da51, Clang 9772bf511a, Swift 493db43364)
Target: x86_64-apple-macosx10.9$ xcrun --toolchain swift swiftc StringStaticExtension.swift 
StringStaticExtension.swift:9:7: error: argument type 'String' does not conform to expected type 'Any'
print("foo: \(.foo)")
      ^~~~~~~~~~~~~~
                     as Any

Changing the print call to:

print("foo: \(String.foo)")

fixes the error in both compilers.

Also filed in Radar as 30885036.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 7, 2017

Comment by David Paschich (JIRA)

Thinking about this a second, it may have been a compiler bug that this ever worked; assuming that what's in the parens is a String is probably not the right thing. That said, the diagnostic isn't helpful, and the fixit tries to append "as Any" after the string, which doesn't fix the problem.

@belkadan
Copy link
Contributor

belkadan commented Mar 7, 2017

Whether or not it should have worked, we probably shouldn't have broken it. But it might be too late in 3.1's schedule to make it work again (we're already several betas into Xcode 8.3). You're right about the diagnostic, though.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 7, 2017

Comment by David Paschich (JIRA)

Yeah, sorry I didn't get to trying the beta on our code until now!

@belkadan
Copy link
Contributor

belkadan commented Mar 7, 2017

Thanks for reporting it at all! :-)

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

2 participants