<div>See:</div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170417/035972.html">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170417/035972.html</a></div><div><br></div><div><br><div class="gmail_quote"><div>On Fri, Jun 16, 2017 at 22:32 Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com">cantrell@pobox.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Under these not-yet-implemented plans, if associated value labels are no longer tuple labels, then how will pattern matching work? And what existing pattern matching code will break / continue to work?</div></div><div style="word-wrap:break-word"><div><br></div><div>P</div></div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jun 16, 2017, at 10:22 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_1611559154887191962Apple-interchange-newline"><div><div>Keep in mind that once the latest proposal about enum cases is implemented, these will be at least notionally no longer tuple labels but rather a sugared way of spelling part of the case name. The rules surrounding labels during case matching have only just been revised and approved and have not even yet been implemented. I don’t think it would be wise to fiddle with them again.</div><div><br></div><div><br><div class="gmail_quote"><div>On Fri, Jun 16, 2017 at 21:21 Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com" target="_blank">cantrell@pobox.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Jun 16, 2017, at 5:23 PM, Mark Lacey &lt;<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.com</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jun 16, 2017, at 2:09 PM, Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com" target="_blank">cantrell@pobox.com</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline">On Jun 16, 2017, at 3:43 PM, Mark Lacey &lt;<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.com</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jun 16, 2017, at 1:21 PM, Mark Lacey &lt;<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.com</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline">On Jun 16, 2017, at 11:13 AM, Paul Cantrell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline">On Jun 15, 2017, at 7:17 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_1611559154887191962m_8541429286439924002Apple-interchange-newline"><div><div><br><div class="gmail_quote"><div>On Thu, Jun 15, 2017 at 19:03 Víctor Pimentel &lt;<a href="mailto:vpimentel@tuenti.com" target="_blank">vpimentel@tuenti.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div>On 16 Jun 2017, at 01:55, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><div><br></div><blockquote type="cite"><div><div><div class="gmail_quote"><div>On Thu, Jun 15, 2017 at 17:43 David Hart &lt;<a href="mailto:david@hartbit.com" target="_blank">david@hartbit.com</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div><br></div></div></div><div style="word-wrap:break-word"><div><div>By the way, I’m not attempting to deduce that nobody uses this feature by the fact I didn’t know about it. But I think it’s one interesting datapoint when comparing it to SE-0110.</div></div></div></blockquote><div><br></div><div><br></div></div></div></div><div><div><div class="gmail_quote"><div>SE-0110, **in retrospect**, has had impacts on a lot of users; prospectively, it was thought to be a minor change, even after review and acceptance.</div><div><br></div><div>Keep in mind that this proposed change would also eliminate inline tuple shuffle. For instance, the following code will cease to compile:</div><div><br></div><div><div>let x = (a: 1.0, r: 0.5, g: 0.5, b: 0.5)</div><div>func f(color: (r: Double, g: Double, b: Double, a: Double)) {</div><div>  print(color)</div><div>}</div></div><div>f(color: x)</div><div><br></div><div>It is an open question how frequently this is used. But like implicit tuple destructuring, it currently Just Works(TM) and users may not realize they’re making use of the feature until it’s gone.</div></div></div></div></blockquote><br></div><div><div>It&#39;s much much less used, by looking at open source projects I doubt that a significant portion of projects would have to change code because of this.</div></div></blockquote><div><br></div><div>The reason that I’m urging caution is because, if I recall correctly, that is also what we said about SE-0110 on this list. Then, as now, we were discussing an issue with something left over from the Swift 1 model of tuples. Then, as now, we believed that the feature in question was rarely used. Then, as now, we believed that removing that feature would improve consistency in the language, better both for the compiler and for users. Then, as now, leaving it in was thought to prevent moving forward with other features that could improve Swift.</div></div></div></div></blockquote><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Data:</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I hacked up a regexp that will catch most uses of labeled tuples in pattern matches, e.g. “let (foo: bar) = baz”. That’s what we’re talking about, right?</div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">That’s the obvious example that people find confusing.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Less obvious places that labeled tuple patterns show up are ‘case let’ and ‘case’ (see below).<span class="m_1611559154887191962m_8541429286439924002Apple-converted-space"> </span></div></div></blockquote><div><br></div><div>Okay, I should have looked at your regex and read further. It looks like you were already trying to match these.</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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I did walk the grammar for all occurrences of _pattern_.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I’m only matching named tuple patterns that immediately follow one of the keywords which a pattern follows (for, case, let, var, and catch). As I mentioned, I’m not matching patterns that come later in comma-separated lists. I’m also not matching named tuples inside nested patterns, e.g. let ((a: b), (c: d)).</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">But again, if even the most basic form of this construct is so rare, I doubt more robust matching would turn up that much more usage.</div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word"><div><div>I’m surprised you’re not seeing any uses of ‘case’ with labels.</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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Me too. But I just verified that my pattern does match them.</div></div></blockquote><div><br></div>Are you sure? It doesn’t look like it’s going to match the example I gave due to the leading ‘.’ on the enum case.</div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>Ah! I should have read your original message more carefully. You’re quite right, I only was checking case statements for raw tuples like this:</div><div><br></div><div>    <span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(50,62,125)">case</span><span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures"> </span><span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(50,62,125)">let</span><span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures"> (i: a, f: b):</span></div><div><br></div><div>…and not for anything involving associated values. I hadn’t even considered that associated values would be affected by this, but looking at the grammar it seems they would indeed be.</div><div><br></div><div>Another clumsy regex search, this time for patterns with tuple labels on associated values, turned up 111 results (one per ~3800 lines). Not super common, but certainly nothing to sneeze at. Here they are:</div><div><br></div><div>    <a href="https://gist.github.com/pcantrell/d32cdb5f7db6d6626e45e80011163efb" target="_blank">https://gist.github.com/pcantrell/d32cdb5f7db6d6626e45e80011163efb</a></div><div><br></div><div>Looking through that gist, these usages mostly strike me as being just fine:</div><div><br></div><div><div><font face="Menlo"><span style="font-size:11px">    case .cover(from: .bottom):</span></font></div><div><font face="Menlo"><span style="font-size:11px"><br></span></font></div></div><div><font face="Menlo"><span style="font-size:11px">    case .reference(with: let ref):</span></font></div><div><font face="Menlo"><span style="font-size:11px"><br></span></font></div><div><font face="Menlo"><span style="font-size:11px">    case .update(tableName: let tableName, columnNames: _):</span></font></div><div><br></div><div>I’d even say that removing the tuple labels would make things worse. Consider:</div><div><br></div><div><div><span style="font-size:11px;font-family:Menlo">    case .name(last: let firstName, first: _):  // mistake is clear</span></div><div><div><font face="Menlo"><span style="font-size:11px">    case .name(</span></font><span style="font-family:Menlo;font-size:11px">let</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-size:11px;font-family:Menlo">firstName, _):               // mistake is buried</span></div></div><div><br></div></div><div>In Chris’s original brain-bending example, the confusion is that there’s no “let” after the colon, so Int and Float look like types instead of variable names:</div></div></div><div style="word-wrap:break-word"><div><div><br></div><div><font face="Menlo"><span style="font-size:11px">    let (a : Int, b : Float) = foo()</span></font></div><div><br></div></div></div><div style="word-wrap:break-word"><div><div>However, in the examples in the gist above, most of the patterns either (1) declare variables using a `let` after the colon:</div><div><br></div><div><font face="Menlo"><span style="font-size:11px">    case .reference(with: let ref):</span></font></div><div><br></div><div>…or (2) don’t declare a variable at all:</div><div><br></div><div><font face="Menlo"><span style="font-size:11px">    case .string(format: .some(.uri)):</span></font></div><div><br></div><div>What if we allowed labels on associated values, but required a `let` after the colon to bind a variable?</div><div><br></div><div><div><font face="Menlo"><span style="font-size:11px">    case let .a(b: c):  // disallowed</span></font></div><div><font face="Menlo"><span style="font-size:11px">    case .a(b: let c):  // OK</span></font></div><div><br></div><div>Only 15 of those 111 run afoul of _that_ rule. Here they are:</div><div><br></div><div>    <a href="https://gist.github.com/pcantrell/9f61045d7d7c8d18eeec8ebbef6cd8f8" target="_blank">https://gist.github.com/pcantrell/9f61045d7d7c8d18eeec8ebbef6cd8f8</a></div><div><br></div><div>That’s one breakage every ~28000 lines, which seems much more acceptable. The drawback is that you can’t declare variables for a bunch of associated value en masse anymore; you need one let per value. (See line 2 in that gist.)</div></div></div></div><div style="word-wrap:break-word"><div><div><br></div><blockquote type="cite"><div style="word-wrap:break-word"><div>You might want to try the patch I sent as it will definitely catch any tuple pattern that makes it to the verifier and does have labels.</div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>I’m not set up to build the compiler, unfortunately. One of these days.</div></div></div><div style="word-wrap:break-word"><div><div><br></div><div>P</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>Mark</div><div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">P</div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word"><div><div><br></div><div>Mark</div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Fortunately we do not appear to allow shuffling in these cases. I’m not sure if the human disambiguation is easier here because of the context (‘case let’ and ‘case’), but I don’t recall seeing complain about these being confusing (having said that it’s entirely possible they are very confusing the first time someone sees them, in particular ‘cast let’ and the binding form of ‘case’.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>enum X {</div><div>  case e(i: Int, f: Float)</div><div>}</div><div><br></div><div>let x = X.e(i: 7, f: 12)</div><div><br></div><div>if case let X.e(i: hi, f: bye) = x {</div><div>  print(&quot;(i: \(hi), f: \(bye))&quot;)</div><div>}</div><div><br></div><div>func test(_ x: X, _ a: Int, _ b: Float) {</div><div>  switch x {</div><div>  case .e(i: a, f: b):</div><div>    print(&quot;match values&quot;)</div><div>  case .e(i: let _, f: let _):</div><div>    print(&quot;bind values&quot;)</div><div>  default:</div><div>    break</div><div>  }</div><div>}</div><div><br></div><div>test(X.e(i: 1, f: 2), 1, 2)</div><div>test(X.e(i: 1, f: 2), 3, 4)</div><div><br></div></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I ran that against all 55 projects in swift-source-compat-suite, comprising about over 400,000 lines of Swift code, and found … drumroll … exactly one match:</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(226,226,226);background-color:rgba(2,3,50,0.952941)"><span style="font-size:11px"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(55,191,41)"><br></span></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(226,226,226);background-color:rgba(2,3,50,0.952941)"><span style="font-size:11px"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(55,191,41)">neota (swift-source-compat-suite)$<span class="m_1611559154887191962m_8541429286439924002Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">find project_cache -name &#39;*.swift&#39; -print0 | xargs -0 pcregrep -M &#39;(for|case|let|var|catch)\s+\([a-zA-Z0-9_]+\s*:&#39;</span></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(226,226,226);background-color:rgba(2,3,50,0.952941)"><span style="font-variant-ligatures:no-common-ligatures;font-size:11px">project_cache/RxSwift/RxExample/RxExample-iOSTests/TestScheduler+MarbleTests.swift:                let (time: _, events: events) = segments.reduce((time: 0, events: [RecordedEvent]())) { state, event in</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(226,226,226);background-color:rgba(2,3,50,0.952941)"><span style="font-variant-ligatures:no-common-ligatures;font-size:11px"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div>Caveats about this method:</div><div><br></div><div>• My regexp won’t match second and third patterns in a comma-separated let or case, e.g.:</div><div><br></div><div>   let a = b, (c: d) = e</div><div><br></div><div>• It doesn’t match non-ascii identifiers.</div><div><br></div><div>• This experiment only considers labeled tuples in pattern matches, what I took Chris’s original puzzler to be about. Label-based tuple shuffling is a separate question.</div><div><br></div><div>Still, even if it’s undercounting slightly, one breakage in half a million lines of code should put to rest concerns about unexpected widespread impact.</div><div><br></div><div>(Anything else I’m missing?)</div><div><br></div><div>• • •</div><div><br></div><div>Aside for those who know the tools out there: what would it take to run inspections like this against ASTs instead of using a regex? Could we instrument the compiler as Brent suggested?</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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">If you want to catch *all* of these cases then the patch below will do it by failing the AST verifier when it hits a pattern with labels. If you only want to find the plain let-binding versions of this and not the ‘case let’ and ‘case’ ones, I’d suggest looking at the parser to see if there’s an easy place to instrument (I don’t know offhand).</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Mark</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp</div><div>index b59a7ade23..ba4b2a245d 100644</div><div>--- a/lib/AST/ASTVerifier.cpp</div><div>+++ b/lib/AST/ASTVerifier.cpp</div><div>@@ -2772,6 +2772,13 @@ public:</div><div>     }</div><div> </div><div>     void verifyParsed(TuplePattern *TP) {</div><div>+      for (auto &amp;elt : TP-&gt;getElements()) {</div><div>+        if (!elt.getLabel().empty()) {</div><div>+          Out &lt;&lt; &quot;Labeled tuple patterns are offensive!\n&quot;;</div><div>+          abort();</div><div>+        }</div><div>+      }</div><div>+</div><div>       PrettyStackTracePattern debugStack(Ctx, &quot;verifying TuplePattern&quot;, TP);</div><div>       verifyParsedBase(TP);</div><div>     }</div><div><br></div></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>Or can SourceKit / SourceKitten give a full AST? Or has anybody written a Swift parser in Swift?</div><div><br></div><div>Cheers,</div><div><br></div><div>Paul</div><div><br></div></div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></blockquote></div></div></blockquote></div></blockquote></div><br></div></div></blockquote></div></div></blockquote></div></div>
</div></blockquote></div><br></div></blockquote></div></div>