<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Stupid Compiler Messages &#8211; Wade Tregaskis</title>
	<atom:link href="https://wadetregaskis.com/tags/stupid-compiler-messages/feed/" rel="self" type="application/rss+xml" />
	<link>https://wadetregaskis.com</link>
	<description></description>
	<lastBuildDate>Mon, 01 Jan 2024 23:00:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://wadetregaskis.com/wp-content/uploads/2016/03/Stitch-512x512-1-256x256.png</url>
	<title>Stupid Compiler Messages &#8211; Wade Tregaskis</title>
	<link>https://wadetregaskis.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">226351702</site>	<item>
		<title>&#8216;Fake error&#8217; about immutable values when using popFirst() on Array</title>
		<link>https://wadetregaskis.com/fake-error-about-immutable-values-when-using-popfirst-on-array/</link>
					<comments>https://wadetregaskis.com/fake-error-about-immutable-values-when-using-popfirst-on-array/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Tue, 13 Feb 2018 05:38:57 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Bugs!]]></category>
		<category><![CDATA[lies]]></category>
		<category><![CDATA[Stupid Compiler Messages]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[What do you want?]]></category>
		<guid isPermaLink="false">https://blog.wadetregaskis.com/?p=4081</guid>

					<description><![CDATA[It&#8217;s been a while since I wrote any meaningful Swift. &#160;How I&#160;didn&#8217;t miss the Swift compiler&#8217;s bullshit error messages. That yields, on the popFirst() method: Cannot use mutating member on immutable value: 'someArray' is immutable. No it&#8217;s not. &#160;It&#8217;s simply not. For whatever reason, if you instead call popFirst() on ArraySlice &#8211; ostensibly indistinguishable from&#8230; <a class="read-more-link" href="https://wadetregaskis.com/fake-error-about-immutable-values-when-using-popfirst-on-array/" data-wpel-link="internal">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>It&#8217;s been a while since I wrote any meaningful Swift. &nbsp;How I&nbsp;<em>didn&#8217;t</em> miss the Swift compiler&#8217;s bullshit error messages.</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled" data-code-block-pro-font-family="" style="font-size:.875rem;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">var</span><span style="color: #000000"> someArray = [</span><span style="color: #A31515">&quot;Foo&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;Bar&quot;</span><span style="color: #000000">]</span></span>
<span class="line"></span>
<span class="line"><span style="color: #AF00DB">if</span><span style="color: #000000"> </span><span style="color: #0000FF">let</span><span style="color: #000000"> foo = someArray.</span><span style="color: #795E26">popFirst</span><span style="color: #000000">() {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #795E26">print</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;Who cares, we never get here anyway.&quot;</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>That yields, on the <code>popFirst()</code> method:</p>



<pre class="wp-block-preformatted">Cannot use mutating member on immutable value: 'someArray' is immutable.</pre>



<p>No it&#8217;s not. &nbsp;It&#8217;s simply not.</p>



<p>For whatever reason, if you instead call <code>popFirst()</code> on <code>ArraySlice</code> &#8211; ostensibly indistinguishable from a real <code>Array</code> &#8211; it works just fine.</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled" data-code-block-pro-font-family="" style="font-size:.875rem;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">var</span><span style="color: #000000"> someArray = [</span><span style="color: #A31515">&quot;Foo&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;Bar&quot;</span><span style="color: #000000">][</span><span style="color: #098658">0</span><span style="color: #000000">...]</span></span>
<span class="line"></span>
<span class="line"><span style="color: #AF00DB">if</span><span style="color: #000000"> </span><span style="color: #0000FF">let</span><span style="color: #000000"> foo = someArray.</span><span style="color: #795E26">popFirst</span><span style="color: #000000">() {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #795E26">print</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;Yet this works correctly.&quot;</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Sigh.</p>



<p>I presume it&#8217;s trying to tell me something stupidly obscure about Swift&#8217;s byzantine type system. &nbsp;Good luck finding out what. &nbsp;Good luck even finding the definition of the <code>popFirst()</code> method, since Xcode claims it doesn&#8217;t exist if you Command-Control-click on it. &nbsp;But Xcode can&#8217;t find most things, so that in itself says very little.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wadetregaskis.com/fake-error-about-immutable-values-when-using-popfirst-on-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4081</post-id>	</item>
		<item>
		<title>Stupid Swift error message #a bajillion and one</title>
		<link>https://wadetregaskis.com/stupid-swift-error-message-a-bajillion-and-one/</link>
					<comments>https://wadetregaskis.com/stupid-swift-error-message-a-bajillion-and-one/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 07 Jan 2017 19:27:42 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[Stupid Compiler Messages]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[What do you want?]]></category>
		<guid isPermaLink="false">https://blog.wadetregaskis.com/?p=3841</guid>

					<description><![CDATA[Input code: Push button. &#160;Expect results (or at least bacon). &#160;Get: Foo.swift:76:21: error: expected ',' separator .day: { String($0 + 1) }, ^ , Foo.swift:76:21: error: expected expression in list of expressions .day: { String($0 + 1) }, ^ Foo.swift:76:21: error: expected ',' separator .day: { String($0 + 1) }, ^ , Believe it or&#8230; <a class="read-more-link" href="https://wadetregaskis.com/stupid-swift-error-message-a-bajillion-and-one/" data-wpel-link="internal">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>Input code:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled" data-code-block-pro-font-family="" style="font-size:.875rem;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">let</span><span style="color: #000000"> componentsOfPotentialInterest = [Calendar.</span><span style="color: #001080">Component</span><span style="color: #000000">: ((</span><span style="color: #267F99">Int</span><span style="color: #000000">) -&gt; </span><span style="color: #267F99">String</span><span style="color: #000000">)](</span></span>
<span class="line"><span style="color: #000000"> .</span><span style="color: #001080">day</span><span style="color: #000000">: { </span><span style="color: #267F99">String</span><span style="color: #000000">(</span><span style="color: #0000FF">$0</span><span style="color: #000000"> + </span><span style="color: #098658">1</span><span style="color: #000000">) },</span></span>
<span class="line"><span style="color: #000000">)</span></span></code></pre></div>



<p>Push button. &nbsp;Expect results (or at least bacon). &nbsp;Get:</p>



<pre class="wp-block-preformatted">Foo.swift:76:21: error: expected ',' separator
 .day: { String($0 + 1) },
     ^
     ,
Foo.swift:76:21: error: expected expression in list of expressions
 .day: { String($0 + 1) },
     ^
Foo.swift:76:21: error: expected ',' separator
 .day: { String($0 + 1) },
     ^
     ,</pre>



<p>Believe it or not, Swift, blindly&nbsp;repeating your obtuse error messages does not help.</p>



<p>What it&#8217;s&nbsp;<em>trying</em> but as usual failing miserably to tell me is that Dictionary doesn&#8217;t have an initialiser that takes key: value pairs (my mistake for writing straight-forward, Python-like code). &nbsp;You have to&nbsp;use the dictionary literal syntax instead:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled" data-code-block-pro-font-family="" style="font-size:.875rem;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">let</span><span style="color: #000000"> componentsOfPotentialInterest: [Calendar.Component: ((</span><span style="color: #267F99">Int</span><span style="color: #000000">) -&gt; </span><span style="color: #267F99">String</span><span style="color: #000000">)] = [</span></span>
<span class="line"><span style="color: #000000"> .</span><span style="color: #001080">day</span><span style="color: #000000">: { </span><span style="color: #267F99">String</span><span style="color: #000000">(</span><span style="color: #0000FF">$0</span><span style="color: #000000"> + </span><span style="color: #098658">1</span><span style="color: #000000">) },</span></span>
<span class="line"><span style="color: #000000">]</span></span></code></pre></div>



<p>Now it merely complains about the expression being <a href="https://wadetregaskis.com/big-words-hurt-swifts-tiny-little-brain/" data-wpel-link="internal">too complex for its pathetic little brain</a>, rather than having no fucking clue what you&#8217;re doing to begin with.  Pick your utterly useless poison, I suppose.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wadetregaskis.com/stupid-swift-error-message-a-bajillion-and-one/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3841</post-id>	</item>
		<item>
		<title>Big words hurt Swift&#8217;s tiny little brain</title>
		<link>https://wadetregaskis.com/big-words-hurt-swifts-tiny-little-brain/</link>
					<comments>https://wadetregaskis.com/big-words-hurt-swifts-tiny-little-brain/#comments</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 07 Jan 2017 19:04:02 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[Stupid Compiler Messages]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[What do you want?]]></category>
		<guid isPermaLink="false">https://blog.wadetregaskis.com/?p=3838</guid>

					<description><![CDATA[Foo.swift:75:49: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions let componentsOfPotentialInterest = [(Calendar.Component, ((Int) -&#62; String))]( ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The fuck?]]></description>
										<content:encoded><![CDATA[<pre>Foo.swift:75:49: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
 <strong>let</strong> componentsOfPotentialInterest = [(Calendar.Component, ((Int) -&gt; String))](
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</pre>
<p>The fuck?</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wadetregaskis.com/big-words-hurt-swifts-tiny-little-brain/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3838</post-id>	</item>
		<item>
		<title>ambiguous reference to member &#8216;joined()&#8217;</title>
		<link>https://wadetregaskis.com/ambiguous-reference-to-member-joined/</link>
					<comments>https://wadetregaskis.com/ambiguous-reference-to-member-joined/#comments</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Sat, 17 Dec 2016 19:23:51 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[Stupid Compiler Messages]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[What do you want?]]></category>
		<guid isPermaLink="false">https://blog.wadetregaskis.com/?p=3807</guid>

					<description><![CDATA[You can readily tell that Swift was created by a C++ fanatic, by its fucking obtuse error messages. ⤹ Me &#160; &#160; &#160;&#160;&#160; &#160; &#160; Swift compiler ⤵︎ In today&#8217;s episode of &#8220;what the fuck do you want, compiler?&#8221;, we tackle: foo.swift:186:39: error: ambiguous reference to member 'joined()' log.debug("\(thingies.joined(separator: ",&#160;"))") ^~~~~~~~ Swift.BidirectionalCollection:27:17: note: found this&#8230; <a class="read-more-link" href="https://wadetregaskis.com/ambiguous-reference-to-member-joined/" data-wpel-link="internal">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>You can readily tell that Swift was created by a C++ fanatic, by its fucking obtuse error messages.</p>



<p class="has-text-align-center">⤹ Me &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; Swift compiler ⤵︎</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="459" height="195" src="https://wadetregaskis.com/wp-content/uploads/2016/12/What-Do-You-Want-Rachel-McAdams-Ryan-Gosling-In-The-Notebook-Gif.webp" alt="&quot;What do you want&quot; scene from The Notebook" class="wp-image-3810" srcset="https://wadetregaskis.com/wp-content/uploads/2016/12/What-Do-You-Want-Rachel-McAdams-Ryan-Gosling-In-The-Notebook-Gif.webp 459w, https://wadetregaskis.com/wp-content/uploads/2016/12/What-Do-You-Want-Rachel-McAdams-Ryan-Gosling-In-The-Notebook-Gif-256x109.webp 256w" sizes="(max-width: 459px) 100vw, 459px" /></figure>
</div>


<p>In today&#8217;s episode of &#8220;what the fuck do you want, compiler?&#8221;, we tackle:</p>



<pre class="wp-block-preformatted">foo.swift:186:39: error: ambiguous reference to member 'joined()'
       log.debug("\(thingies.joined(separator: ",&nbsp;"))")
                    ^~~~~~~~
Swift.BidirectionalCollection:27:17: note: found this candidate
 public func joined() -&gt; FlattenBidirectionalCollection&lt;Self&gt;
             ^
Swift.Sequence:27:17: note: found this candidate
 public func joined() -&gt; FlattenSequence&lt;Self&gt;
             ^
Swift.Sequence:18:17: note: found this candidate
 public func joined&lt;Separator : Sequence where Separator.Iterator.Element == Iterator.Element.Iterator.Element&gt;(separator: Separator) -&gt; JoinedSequence&lt;Self&gt;
             ^
Swift.Sequence:16:17: note: found this candidate
 public func joined(separator: String = default) -&gt; String
             ^
Swift.Collection:27:17: note: found this candidate
 public func joined() -&gt; FlattenCollection&lt;Self&gt;
             ^</pre>



<p>For context, &#8216;thingies&#8217; is an array of a custom type.</p>



<p>What the compiler wishes it could say, if it weren&#8217;t incompetent, is that every one of <code>Array</code>&#8216;s <code>joined</code> implementations are&nbsp;<em>conditional</em>. &nbsp;The one that I want is is the second last one, but it is only defined for <code>Array&lt;String&gt;</code> specifically. &nbsp;No other <code>Array</code> types.</p>



<p>Similarly&nbsp;<em>every other one</em> is conditional on the <code>Element</code> type within the <code>Array</code> being a specific type or protocol, none of which happen to apply to the types I&#8217;m using in my <code>Array</code>.</p>



<p>Now, my&nbsp;<em>intuition</em> is that since my type&nbsp;<em>is</em> <code>CustomDebugStringConvertible</code>, that Swift would know then how to convert my type to a <code>String</code> and then go from there. &nbsp;For better or worse, however, it does not. &nbsp;Instead you have to do it manually, e.g.:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled" data-code-block-pro-font-family="" style="font-size:.875rem;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #24292EFF">log.</span><span style="color: #6F42C1">debug</span><span style="color: #212121">(</span><span style="color: #22863A">&quot;</span><span style="color: #22863A">\(thingies.</span><span style="color: #6F42C1">map</span><span style="color: #212121">(</span><span style="color: #6F42C1">{ </span><span style="color: #1976D2">String</span><span style="color: #212121">(</span><span style="color: #6F42C1">describing</span><span style="color: #212121">:</span><span style="color: #6F42C1"> $0</span><span style="color: #212121">)</span><span style="color: #6F42C1"> }</span><span style="color: #212121">)</span><span style="color: #22863A">.</span><span style="color: #6F42C1">joined</span><span style="color: #212121">(</span><span style="color: #6F42C1">separator</span><span style="color: #212121">:</span><span style="color: #6F42C1"> </span><span style="color: #22863A">&quot;, &quot;</span><span style="color: #212121">)</span><span style="color: #22863A">)</span><span style="color: #22863A">&quot;</span><span style="color: #212121">)</span></span></code></pre></div>



<p>And you can probably tell from that alone that I&#8217;m very used to Objective-C, where it&#8217;s very easy to write what you intend <em>and</em> get the results you intend.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wadetregaskis.com/ambiguous-reference-to-member-joined/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			<media:content url="https://wadetregaskis.com/wp-content/uploads/2016/12/What-Do-You-Want-Rachel-McAdams-Ryan-Gosling-In-The-Notebook-Gif.webp" medium="image" />
<post-id xmlns="com-wordpress:feed-additions:1">3807</post-id>	</item>
	</channel>
</rss>
