Skip to content

Conversation

@CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 12, 2016

This patch is an extension to optional-as-any warnings introduced to diagnose cases where an optional expression was being upcast to Any by mistake. We now emit a warning in the case that a user writes an optional-typed expression in a string interpolation segment. In addition, we offer fixits to help the user either explicitly request this with String(describing:) or offer to insert the start of a default value expression. As a warning this change is not source-breaking and fairly low risk.

@jrose-apple @rudkx How does it look?

Basic extension of the optional-to-any AST walker to incorporate
warnings for optionally-typed expressions in string interpolation
segments that can lead to unintended behavior.  Specifically

let x = Optional<Int>.some(2)
print(x) // "Optional(2)"
@CodaFi CodaFi changed the title Warn for Optionals in String Interpolation Segments [3.0] Warn for Optionals in String Interpolation Segments Oct 12, 2016
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 12, 2016

@swift-ci please test OS X platform.

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 17, 2016

@jrose-apple bump

@jrose-apple
Copy link
Contributor

I think at this point we're only taking critical changes on the 3.0 branch.

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 18, 2016

Very well, just needed some clarification.

@CodaFi CodaFi closed this Oct 18, 2016
@CodaFi CodaFi deleted the optional-practical-training branch December 22, 2019 02:59
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

Successfully merging this pull request may close these issues.

3 participants