<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="">Ok, I submitted a bug report (<a href="https://bugs.swift.org/browse/SR-4347" class="">https://bugs.swift.org/browse/SR-4347</a>) and I'll try to fix it in the<div class="">next few days.</div><div class=""><br class=""></div><div class="">Thanks and best regards</div><div class="">Toni</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 24.03.2017 um 18:51 schrieb Mark Lacey <<a href="mailto:mark.lacey@apple.com" class="">mark.lacey@apple.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Mar 24, 2017, at 3:08 AM, Toni Suter 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="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div class=""><br class=""></div><div class="">If I declare a variable and initialize it with an array literal whose elements are integer literals and nil literals,</div><div class="">the compiler will infer the type Array<Optional<Int>> for that variable:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let arr = [1, nil, 3]</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">print(type(of: arr))<span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre;">        </span>// Array<Optional<Int>></font></div></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class=""><div class="">However, that only works with nominal types such as Int and String. If I do the same thing with an array of tuples,</div><div class="">I get a compile error:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let arr = [(1, false), nil, (3, true)]<span class="Apple-tab-span" style="white-space: pre;">                </span>// error: type of expression is ambiguous without more context</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">print(type(of: arr))</font></div></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="">Why can't the compiler infer the type Array<Optional<(Int, Bool)>> in this example? Is there a reason for this or is it a bug?</div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Offhand it seems like we should be able to properly handle this. Can you open a bug report at<span class="Apple-converted-space"> </span><a href="http://bugs.swift.org/" class="">bugs.swift.org</a>?</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Mark</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">Thanks and best regards,</div><div class="">Toni</div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div></blockquote></div><br class=""></div></body></html>