<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="">Adrian Prantl wrote:<br class=""><blockquote type="cite" class="">Nitpick: #setline is not really a statement, a better name for the production would be “line-control-directive” as it may appear everywhere a newline character may appear in the grammar.</blockquote><div class=""><br class=""></div><div class="">Agreed.</div><div class=""><br class=""></div><div class="">The reference doesn't currently separate directives (#if and #setline and so on) into their own chapter. Given the list of chapters it does have, Statements was the least incorrect place to discuss these.</div><div class=""><br class=""></div><div class="">We'll have to revisit the naming on these "statements" that aren't quite statements in the grammar. This is very closely related to the recent change to rename "build configurations" to "conditional compilation blocks". (As commit 6272941 did for compiler diagnostics.)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Brent Royal-Gordon wrote:<br class=""></div><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""></blockquote></blockquote></blockquote><blockquote type="cite" class="">Does that mean the filename is always required? This is uncommon in other languages that support #line, though it looks like Swift 2 imposes the same requirement.<br class=""></blockquote><div class=""><br class=""></div><div class="">You're correct, that is the current behavior (see below). Do you have an example use case for setting the line number without setting the file name?</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%</span> cat -n test.swift</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 1<span class="Apple-tab-span" style="white-space:pre">        </span>print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 2<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 3<span class="Apple-tab-span" style="white-space:pre">        </span>print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 4<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 5<span class="Apple-tab-span" style="white-space:pre">        </span>#line 100</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 6<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 7<span class="Apple-tab-span" style="white-space:pre">        </span>print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 8<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 9<span class="Apple-tab-span" style="white-space:pre">        </span>#line 100 "filename"</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 10<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 11<span class="Apple-tab-span" style="white-space:pre">        </span>print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 12<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 13<span class="Apple-tab-span" style="white-space:pre">        </span>#line</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 14<span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""> 15<span class="Apple-tab-span" style="white-space:pre">        </span>print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">%<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> swift test.swift </span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><b class="">test.swift:7:1: </b><span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class=""><b class="">error: </b></span><b class="">expected filename string literal for #line directive</b></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class="">print("On line \(#line) in file \(#file)")</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38);" class=""><b class="">^</b></div></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38);" class=""><b class=""><br class=""></b></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38);" class=""><b class=""><br class=""></b></div></body></html>