<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>If you don't think this needs a proposal, then Robert has an implementation almost done. We could submit a PR later today.<br><br>- Harlan</div><div><br>On Oct 3, 2016, at 4:06 PM, Mark Lacey via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 3, 2016, at 11:26 AM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 3, 2016, at 11:02 AM, Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="">devteam.codafi@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Because the initializer here doesn’t take Any, it takes &lt;T&gt;.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I think there's a case to be made to generalize the 'Any' warning to Optional implicitly being deduced as a type variable binding in any unconstrained context. What exactly constitutes 'implicit' and 'unconstrained' is up for debate, though, and probably needs some experimentation to figure out what feels good. For instance, explicitly constructing an optional is a signal the optionality intentional. Potentially, having multiple Optional parameters binding the same type variable also increases the likelihood it's intended, for example:</div><div class=""><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class="">func foo&lt;T&gt;(x: T, y: T) {}</div></div><div class=""><div class=""><br class=""></div></div><div class=""><div class="">var x: Int? = 1</div></div><div class=""><div class="">var y: Int = 2</div></div><div class=""><div class="">foo(x, y) // One Optional isn't unwrapped, forcing the other to promote. Maybe a mistake?</div></div><div class=""><div class="">var z: Int? = 3</div></div><div class=""><div class="">foo(x, z) // Two T parameters are Optional. Probably intentional?</div></div></blockquote><div class=""><div class=""><br class=""></div><div class="">Regardless of whether there's a more general principle we can base a warning on, string interpolation and String(describing:) are common enough pitfalls that they may just deserve special case treatment.</div></div></div></div></blockquote><div><br class=""></div><div>I think string interpolation could be handled pretty easily with a warning by extending the existing warning for Any. We just need to look at interpolation expressions and if any of the segments are optional-typed emit a warning unless they are explicitly casted to the optional type. The fixit can suggest explicit casting or using the debugDescription.</div><div><br class=""></div><div>I’m not sure we really need an evolution proposal for that.</div><div><br class=""></div><div>As for the more general topic of trickiness around optional injection into unconstrained generics: Yes, we should review that at some point as well. I recall seeing at least one concrete complaint about surprising behavior resulting from doing this in generic functions, but I cannot find the bug at the moment.</div><div><br class=""></div><div>Mark</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""></div><div class="">-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">~Robert Widmann</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 3, 2016, at 2:00 PM, Harlan Haskins via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Unfortunately, Optional-to-Any does not currently hit this case because IIRC it doesn't promote to Any in an interpolation segment. I tested this with a ToT build yesterday.</div><div class=""><br class=""></div><div class="">- Harlan</div><div class=""><br class=""></div><div class="">On Oct 3, 2016, at 1:57 PM, Joe Groff &lt;<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class="">We now emit a warning whenever an optional is used as an Any. I disagree that this should be an error, but it seems reasonable to warn (if we don't already thanks to the 'Any' warning).<div class=""><br class=""></div><div class="">-Joe</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><span class=""></span></div><div class=""><div class="">Hey all,</div><div class=""><br class=""></div><div class="">Julio Carrettoni, Robert Widmann, and I have been working on a proposal to mitigate something that's burned us all since Swift 1. We'd love some feedback!</div><div class=""><br class=""></div><div class="">It's available here:&nbsp;<a href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd" class="">https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd</a></div><div class=""><br class=""></div><div class="">I've posted the current draft below.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Harlan Haskins<br class=""></div><div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); margin-top: 0px !important;" class=""><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Disallow Optionals in String Interpolation Segments</span></font></h1><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;" class=""><li style="box-sizing: border-box;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Proposal:&nbsp;<a href="https://gist.github.com/harlanhaskins/NNNN-filename.md" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">SE-NNNN</a></span></li><li style="box-sizing: border-box; margin-top: 0.25em;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Authors:&nbsp;<a href="https://github.com/harlanhaskins" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">Harlan Haskins</a>,&nbsp;<a href="https://github.com/Julioacarrettoni" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">Julio Carrettoni</a>,&nbsp;<a href="https://github.com/CodaFi" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">Robert Widmann</a></span></li><li style="box-sizing: border-box; margin-top: 0.25em;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Review Manager: TBD</span></li><li style="box-sizing: border-box; margin-top: 0.25em;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Status:&nbsp;<span style="box-sizing: border-box; font-weight: 600;" class="">Awaiting revie</span></span></li></ul><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-introduction" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#introduction" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Introduction</span></font></h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Swift developers frequently use string interpolation as a convenient, concise syntax for interweaving variable values with strings. The interpolation machinery, however, has surprising behavior in one specific case:&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional&lt;T&gt;</code>. If a user puts an optional value into a string interpolation segment, it will insert either&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">"Optional("value")"</code>&nbsp;or&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">"nil"</code>&nbsp;in the resulting string. Neither of these is particularly desirable, so we propose a warning and fix-it to surface solutions to these potential mistakes.</span></p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">Discussion thread topic for that proposal</a></span></p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-motivation" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#motivation" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Motivation</span></font></h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><em style="box-sizing: border-box;" class="">The Swift Programming Language</em>&nbsp;defines string interpolation segments as "a way to construct a new String value from a mix of constants, variables, literals, and expressions". There is one type that runs counter to this definition:&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>. The&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">.none</code>&nbsp;case in particular is used to indicate the absence of a value. Moreover, its inclusion in interpolation segments leads to the dreaded&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">"nil"</code>&nbsp;in output that is often fed to UI elements. Even barring that, interpolating a non-nil optional value yields&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">"Optional("value")"</code>, a result that is not useful even in logged output.</span></p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Given that the&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>&nbsp;type is never fit for display to the end user, and can often be a surprising find in the console, we propose that requesting an&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>'s debug description be an explicit act. This proposal now requires a warning when using an expression of&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>&nbsp;type within a string interpolation segment.</span></p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-proposed-solution" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#proposed-solution" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Proposed solution</span></font></h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">The user will be warned after attempting to use an expression with type&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional&lt;T&gt;</code>&nbsp;in a string interpolation segment. They will then be offered a fixit suggesting they explicitly request the&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">debugDescription</code>&nbsp;of the&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>&nbsp;value instead.</span></p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-detailed-design" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#detailed-design" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Detailed design</span></font></h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Semantic analysis currently does not do much but guarantee the well-formedness of expressions in interpolation segments. These are then fed directly to&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">String.init(stringInterpolationSegment:)</code>&nbsp;and are run through the runtime reflection system to generate a description. Semantic analysis will be tweaked to inspect the result of solving an interpolation segment for an&nbsp;<code style="box-sizing: border-box; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Optional</code>&nbsp;and will offer a fixit in that case.</span></p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-impact-on-existing-code" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#impact-on-existing-code" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Impact on existing code</span></font></h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">As this is a warning, code written before this proposal will continue to compile and run with the same semantics as before. Authors of code that makes use of this unsafe pattern will be offered a migration path to the safer, more explicit form.</span></p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238);" class=""><a id="user-content-alternatives-considered" class="anchor" href="https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd#alternatives-considered" aria-hidden="true" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"></svg><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" class=""></path></span></font></a><font size="3" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Alternatives considered</span></font></h2><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 0px !important;" class=""><li style="box-sizing: border-box;" class=""><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">A fixit that suggests a default value be inserted would be entirely appropriate (following the style of the fixit introduced in&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0140-bridge-optional-to-nsnull.md" style="box-sizing: border-box; -webkit-text-decoration-skip: objects; text-decoration: none;" class="">SE-0140</a>).</span></p></li><li style="box-sizing: border-box; margin-top: 0.25em;" class=""><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">Forbidding this pattern by hard error would make this proposal a breaking change that is out of scope for this stage of Swift's development.</span></p></li><li style="box-sizing: border-box; margin-top: 0.25em;" class=""><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">A fixit that introduces a force-unwrapping would technically work as well, however it would be fixing a dangerous operation with yet another dangerous operation.</span></p></li></ul></div></div><div class=""><br class=""><br class="">Sent from my iPad</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>