<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">You&#39;d have to ask Chris Latter and Dmitri Gribenko, who are responsible for the lines in Lexer.cpp that prevent it: </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><table class="" style="border-collapse:collapse;border-spacing:0px;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px;line-height:18.2px"><tbody><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" rowspan="3" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" class="" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;float:right;background-color:transparent"><br class="">22610d5</a><img alt="@lattner" class="" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&amp;s=64" width="32" style="border: 0px; display: inline-block; overflow: hidden; line-height: 1; vertical-align: middle; border-radius: 3px; float: left; margin-right: 5px;"><span class="" style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" class="" title="substantially improve error recovery for erroneous character and string literals.
Before we&#39;d emit multiple diagnostics and confuse the lexer in some really common
cases (e.g. malformed escapes).


Swift SVN r5242" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent">substantially improve error recovery for erroneous character and stri…</a></span><div class="" style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" class="" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent">lattner</a> authored on May 20, 2013</div></td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1147" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1147</td><td class="" id="LC1147" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal"></td></tr><tr class=""><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1148" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1148</td><td class="" id="LC1148" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">    <span class="" style="color:rgb(150,152,150)">// String literals cannot have \n or \r in them.</span></td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" rowspan="2" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47" class="" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;float:right;background-color:transparent">3bee330</a><img alt="@gribozavr" class="" height="32" src="https://avatars1.githubusercontent.com/u/1120569?v=3&amp;s=64" width="32" style="border: 0px; display: inline-block; overflow: hidden; line-height: 1; vertical-align: middle; border-radius: 3px; float: left; margin-right: 5px;"><span class="" style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47" class="" title="Lexer: don&#39;t inf loop on an unterminated string literal near EOF


Swift SVN r7474" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent">Lexer: don&#39;t inf loop on an unterminated string literal near EOF</a></span><div class="" style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/gribozavr" class="" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent">gribozavr</a> authored on Aug 22, 2013</div></td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1149" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1149</td><td class="" id="LC1149" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">    <span class="" style="color:rgb(167,29,93)">if</span> (*CurPtr == <span class="" style="color:rgb(24,54,145)"><span class="">&#39;</span><span class="">\r</span><span class="">&#39;</span></span> || *CurPtr == <span class="" style="color:rgb(24,54,145)"><span class="">&#39;</span><span class="">\n</span><span class="">&#39;</span></span> || CurPtr == BufferEnd) {</td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" rowspan="4" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" class="" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;float:right;background-color:transparent">22610d5</a><img alt="@lattner" class="" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&amp;s=64" width="32" style="border: 0px; display: inline-block; overflow: hidden; line-height: 1; vertical-align: middle; border-radius: 3px; float: left; margin-right: 5px;"><span class="" style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" class="" title="substantially improve error recovery for erroneous character and string literals.
Before we&#39;d emit multiple diagnostics and confuse the lexer in some really common
cases (e.g. malformed escapes).


Swift SVN r5242" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent">substantially improve error recovery for erroneous character and stri…</a></span><div class="" style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" class="" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent">lattner</a> authored on May 20, 2013</div></td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1150" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1150</td><td class="" id="LC1150" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">      <span class="" style="color:rgb(0,134,179)">diagnose</span>(TokStart, diag::lex_unterminated_string);</td></tr><tr class=""><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1151" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1151</td><td class="" id="LC1151" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">      <span class="" style="color:rgb(167,29,93)">return</span> <span class="" style="color:rgb(0,134,179)">formToken</span>(tok::unknown, TokStart);</td></tr><tr class=""><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1152" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1152</td><td class="" id="LC1152" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">    }</td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" rowspan="2" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2" class="" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;float:right;background-color:transparent">2f44c00</a><img alt="@lattner" class="" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&amp;s=64" width="32" style="border: 0px; display: inline-block; overflow: hidden; line-height: 1; vertical-align: middle; border-radius: 3px; float: left; margin-right: 5px;"><span class="" style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2" class="" title="Initial stab at implementing string literal interpolation for simple expressions,
e.g. &quot;foo is \(i+j)&quot;.  This implements rdar://11223686

Doug implemented all the hard parts of this.  I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress.  I plan a few refinements
on top of this basic patch.



Swift SVN r1738" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent">Initial stab at implementing string literal interpolation for simple …</a></span><div class="" style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" class="" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent">lattner</a> authored on May 4, 2012</div></td></tr><tr class="" style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td class="" style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td class="" id="L1153" style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;line-height:18px;color:rgba(0,0,0,0.298039);vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1153</td><td class="" id="LC1153" style="padding:0px 10px;vertical-align:top;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;white-space:pre;overflow:visible;word-wrap:normal">    </td></tr></tbody></table></div><div class="gmail_extra"><br><div class="gmail_quote"><br></div><div class="gmail_quote">On Sat, Dec 12, 2015 at 2:02 AM, Alex Gordon <span dir="ltr">&lt;<a href="mailto:alextgordon@gmail.com" target="_blank">alextgordon@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>What is the reason that normal strings &quot;...&quot; don&#39;t support newlines? It&#39;s not traditionally seen in C-inspired languages, but it&#39;s hardly unusual outside that sphere[*]. Ruby and HTML are probably the most common examples, but apparently OCaml and Lisps also allow it?</div><div><br></div><div>Then we can simply use</div><div><br></div><div>1. &quot;...&quot; strings as the verbatim literal, preserving indentation and leading newlines as written.</div><div><br></div><div>2. &quot;&quot;&quot;...&quot;&quot;&quot; strings as the non-verbatim literal, reducing indentation to that of the least indented line, and removing the leading newline if it exists.</div><div><br></div><div>[*] As seen earlier <a href="http://rigaux.org/language-study/syntax-across-languages.html#StrngMltLine" target="_blank">http://rigaux.org/language-study/syntax-across-languages.html#StrngMltLine</a></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sat, Dec 12, 2015 at 6:25 AM, Travis Tilley via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif">That&#39;s another great example that I hadn&#39;t even thought of.</span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif"><br></span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif"><br></span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif">- Travis Tilley</span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif"><br></span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif"><br></span></div><div style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif">On Fri, Dec 11, 2015 at 7:43 PM, Jason Dusek </span><span dir="ltr" style="font-family:arial,sans-serif">&lt;<a href="mailto:jason.dusek@gmail.com" target="_blank">jason.dusek@gmail.com</a>&gt;</span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><p style="margin:1.2em 0px!important">One use case for a slightly richer approach to indentation erasure — one that I encounter every day — is inline SQL. If it’s 10 lines or more, it should probably find expression as a <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">VIEW</code> or stored procedure; but queries like this are not unusual:<br></p></span>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span><span style="color:rgb(51,51,51);font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">findMentions</span><span>(account: String)</span> -&gt; <span style="color:rgb(153,0,0);font-weight:bold">Array</span><span>&lt;String&gt;</span> </span>{
    <span style="color:rgb(51,51,51);font-weight:bold">let</span> db = databaseFactory().findDatabase()
    <span style="color:rgb(51,51,51);font-weight:bold">let</span> q = `​``<span style="color:rgb(68,85,136);font-weight:bold">SELECT</span> array_agg(<a href="http://mentioner.id" target="_blank">mentioner.id</a>)
                 <span style="color:rgb(68,85,136);font-weight:bold">FROM</span> account
                 <span style="color:rgb(68,85,136);font-weight:bold">JOIN</span> mention <span style="color:rgb(68,85,136);font-weight:bold">ON</span> (<a href="http://account.id" target="_blank">account.id</a> = mentioned)
                 <span style="color:rgb(68,85,136);font-weight:bold">JOIN</span> account <span style="color:rgb(68,85,136);font-weight:bold">AS</span> mentioner <span style="color:rgb(68,85,136);font-weight:bold">ON</span> (<a href="http://mentioner.id" target="_blank">mentioner.id</a> = mentioner)
                <span style="color:rgb(68,85,136);font-weight:bold">WHERE</span> account.handle = :<span style="color:rgb(0,128,128)">1</span>
                <span style="color:rgb(68,85,136);font-weight:bold">ORDER</span> <span style="color:rgb(68,85,136);font-weight:bold">BY</span> timestamp <span style="color:rgb(68,85,136);font-weight:bold">DESC</span>
                <span style="color:rgb(68,85,136);font-weight:bold">LIMIT</span> <span style="color:rgb(0,128,128)">1</span>`​``

    <span style="color:rgb(51,51,51);font-weight:bold">return</span> db.query(q).parameterize(account).run()
}
</code></pre>
<p style="margin:1.2em 0px!important">Moving everything below <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">q</code> seems infelicitous, at best. However, I do see the appeal of basing the rule on the position of the backticks.</p>
<p style="margin:1.2em 0px!important">Best Regards,</p><p style="margin:1.2em 0px!important">Jason Dusek</p></div></blockquote><div> </div></div>
</div></div>
</div></div><span class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ufQ1sKmNNtjEC-2BBUON-2BgZPd8t-2F4PFTin0qlI9lRM0AlI2I3pNy2PX4maTqYBy7ZknqADue9VJ1l1LYgn-2BokspEFOrXcJ8-2BaRpStVNA1SVTwxLUYE97lepIm49101-2FSys92h5oy45p-2Bn9sAP5Vw1skI3eeqqOJRo5ocCKWzxlgPk6id9EE-2F2-2FSIjvMAMvza0Sj1XFnwt8N5mmnhz3-2BMuqXBWqlTHZ4UYLh-2FOVtQLNfYY-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></blockquote></div></div></blockquote></div>
</div></div>