<div dir="ltr"><div><div><div><div><div><div>The bug is that (true ifTrue:[^true] ifFalse:[^false]) won&#39;t push any value on the stack (same as emitEffect: rather than emitValue:)<br></div>The decompiler wants to find the argument of self value: ... on the stack and it&#39;s not there.<br>
<br></div>So either we should forbid such construct at compile time<br>(emit an &#39;un-reachable code&#39; error when emitValue: does not emit any value)<br><br></div>Or patch Decompiler like mad to work around...<br>(but Decompiler&#39;s methods are yet well below usual quality in term of complexity - long methods, many instance variables, incredibly complex state, ...)<br>
<br></div>I agree, this is going to be a rare problem only for newbies, because an experimented Smalltalker will avoid writing unreachable code.<br></div>So, the third solution is DO NOTHING, or more exactly add a test and an expected failure.<br>
</div><div>Like that we&#39;ll say next time, hey bad luck, this is a known limitation.<br></div><div><br></div>Nicolas<br><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/20 Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 20 June 2013 02:12, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>

&gt; On Thu, Jun 20, 2013 at 01:26:14AM +0200, Nicolas Cellier wrote:<br>
&gt;&gt; See<br>
&gt;&gt; <a href="http://stackoverflow.com/questions/17129583/smalltalk-collection-is-empty-error-when-saving/17202938#17202938" target="_blank">http://stackoverflow.com/questions/17129583/smalltalk-collection-is-empty-error-when-saving/17202938#17202938</a><br>

&gt;&gt;<br>
&gt;&gt; This bug was found by a newbie on pharo 1.1, but it&#39;s still there in 4.5<br>
&gt;&gt; trunk image<br>
&gt;&gt;<br>
&gt;&gt; Try to decompile this (no matter in which class)<br>
&gt;&gt;<br>
&gt;&gt; &lt; aNumberWithUnits<br>
&gt;&gt;     (self compareUnits: aNumberWithUnits)<br>
&gt;&gt;         ifTrue: [self value: ((aNumberWithUnits value) &lt; (self value)<br>
&gt;&gt; ifTrue: [^true] ifFalse: [^false]).]<br>
&gt;&gt;         ifFalse: [^Error new signal: &#39;Incompatible unit types.&#39;].<br>
&gt;&gt;<br>
&gt;&gt; Thanks to the newbie!<br>
&gt;&gt; I would just have hated that!<br>
&gt;&gt; Learning from one&#39;s own error is great, but from a dysfunctional system not<br>
&gt;&gt; so :(<br>
&gt;<br>
&gt; Good bug catch! Here is a reduced version of the method that produces the<br>
&gt; same error when decompiled:<br>
&gt;<br>
&gt;<br>
&gt;   Foo&gt;&gt;decompilerBug<br>
&gt;       self value: (true<br>
&gt;           ifTrue: [^ true]<br>
&gt;           ifFalse: [^ false])<br>
<br>
</div></div>I&#39;m guessing that this is because<br>
<div class="im"><br>
true<br>
  ifTrue: [^ true]<br>
  ifFalse: [^ false]<br>
<br>
</div>decompiles as<br>
<br>
true ifTrue: [^ true]<br>
^ false<br>
<br>
?<br>
<br>
I&#39;m not terribly worried about claims of a &quot;dysfunctional system&quot;.<br>
This bug is so severe that noone has noticed it before! I agree that<br>
we need to fix the bug, but the original code makes no sense in the<br>
first place. #value: is unreachable.<br>
<br>
frank<br>
<br>
&gt; Dave<br>
&gt;<br>
&gt;<br>
<br>
</blockquote></div><br></div>