<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I personally find it kind of weird that `let x = 0; do { let x = x + 1 }` is disallowed but `let x: Int? = 0; if let x = x { }` is allowed. The former case requires you first rename the variable you plan to shadow, inconveniently:<div class=""><br class=""></div><div class="">```</div><div class="">let x = 0</div><div class="">do {</div><div class="">&nbsp; let tempX = x // ew</div><div class="">&nbsp; let x = tempX + 1</div><div class="">}</div><div class="">```<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 30, 2017, at 11:56 AM, Robert Widmann 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=""><div class="">This seems like it’s running through the same check that disallows defining and calling a closure&nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> randomFunc : () -&gt; () = randomFunc()</span></div></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 30, 2017, at 2:37 PM, Michael Gubik 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=""><div class="">Example that does not compile:<br class=""><br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let randomArray = randomArray(withCapacity: 4096)<br class=""><br class="">Compiler error: “Variable used within its own initial value”<br class="">The variable name unfortunately clashes with the function name.<br class=""><br class="">This problem forces the developer to think about an alternative name.<br class="">IMHO that’s suboptimal since many times the most canonical naming would be one where these two go by the same name.<br class=""><br class="">It’s not a big problem in practice but I wonder if there are plans to change this?<br class=""><br class=""><br class="">Thanks,<br class="">Michael Gubik<br class=""><br class="">_______________________________________________<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></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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>