<div dir="ltr"><div class="gmail_signature"><div class="gmail_signature">func perhapsConfusing() {</div><div class="gmail_signature"> let s =</div><div class="gmail_signature"> "Since this function compiles fine. One might "</div><div class="gmail_signature"> "think that string literals in Swift can be "</div><div class="gmail_signature"> "written like this. But that is not the case. "</div><div class="gmail_signature"> "Only the first string literal will be printed."</div><div class="gmail_signature"> "The rest (including eg this) will be silently "</div><div class="gmail_signature"> "ignored."</div><div class="gmail_signature"> 12.34 // As will this.</div><div class="gmail_signature"> 12 + 4 // And this.</div><div class="gmail_signature"> 123 == 456 // And this.</div><div class="gmail_signature"> print(s) // Prints: "Since this function compiles fine. One might "</div><div class="gmail_signature">}</div><div class="gmail_signature"><br></div><div>Besides being possibly surprising for newcomers (who may assume string literals split across several lines as above will be joined), there are some related inconsistencies in whether warnings are generated for unused results or not, for example</div><div>123 == 456 // Unused result is silently ignored, while</div><div>1.2 == 3.4 // produces a warning: Result of call to '==' is unused.</div><div>(The following bug report is about unused results, but it doesn't mention the IMHO similar unused-literals-case: <a href="https://bugs.swift.org/browse/SR-245">https://bugs.swift.org/browse/SR-245</a> )</div><div><br></div><div>So my question is:</div><div>Should/could there be a warning for unused literals?</div><div><br></div><div>/Jens</div><div><br></div></div>
</div>