<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 16, 2016, at 10:18 PM, Martin R via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class=""><br class="">I wonder why the Swift compiler does not complain about the<br class="">redeclaration of `number` after the guard-statement in top-level code:<br class=""><br class=""> // main.swift<br class=""> import Swift<br class=""><br class=""> guard let number = Int("1234") else { fatalError() }<br class=""> print(number) // Output: 1234<br class=""> let number = 5678<br class=""> print(number) // Output: 1234<br class=""><br class="">It looks as if the statement `let number = 5678` is completely ignored.<br class=""><br class="">However, doing the same inside a function causes a compiler error:<br class=""><br class=""> func foo() {<br class=""> guard let number = Int("1234") else { fatalError() }<br class=""> print(number)<br class=""> let number = 5678 // error: definition conflicts with previous value<br class=""> }<br class=""><br class="">Tested with<br class="">- Xcode 7.3.1, "Default" and "Snapshot 2016-06-06 (a)" toolchain<br class="">- Xcode 8 beta.<br class=""><br class="">Am I overlooking something or is that a bug?<br class=""></div></div></blockquote><div><br class=""></div><div>Hi Martin,</div><div><br class=""></div>Yes, this looks like a bug. Can you open a report at <a href="http://bugs.swift.org" class="">bugs.swift.org</a>?</div><div><br class=""></div><div>Mark</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">Martin<br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></body></html>