Hi Steph,<div><br></div><div>    this is an interesting bug with Debugger doits inside Debugger doits.  So at the outer level one has some method m0 in the debugger:<br><br></div><div><div>nextEvent</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;Return the next event from the receiver.&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>eventQueue == nil </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ifTrue:[^self nextEventSynthesized]</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ifFalse:[^self nextEventFromQueue]</div>
<div><br></div><div>and in the right-hand context inspector one evaluates the following (which will cause a subscript bounds because there are no temps)</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>ThisContext namedTempAt: 1</div>
<div><br></div><div> to create m1:</div><div><br></div><div><div>DoItIn: ThisContext </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^ ThisContext namedTempAt: 1</div></div><div><br></div><div>If in the debugger on m1 I evaluate e.g. ThisContext I get the below error in the compiler as it is trying to create m2</div>
<div><br></div><div>The underlying bug is that in m2 ThisContext is ambiguous.  It can refer to the context for m1 or, as the programmer intends, the context for m0.  What the programmer means to achieve is an m2 that reads</div>
<div><div><br></div><div><div>DoItIn: ThisContext </div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>^ (ThisContext tempAt: 0) namedTempAt: 1</div></div></div><div><br></div><div>where ThisContext tempAt: 0 accesses thisContext in m0.</div>
<div><br></div><div>The symptom is due to Encoder&gt;&gt;init:context:notifying: binding ThisContext twice in</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>aContext ~~ nil ifTrue:</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>[| homeNode |</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> homeNode := self bindTemp: self doItInContextName.</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> &quot;0th temp = aContext passed as arg&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span> aContext tempNames withIndexDo:</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>[:variable :index|</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>scopeTable</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>at: variable</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>put: (MessageAsTempNode new</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>receiver: homeNode</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>selector: #namedTempAt:</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>arguments: (Array with: (self encodeLiteral: index))</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>precedence: 3</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>from: self)]].</div></div><div><br></div><div>since aContext tempNames includes &#39;ThisContext&#39; which is also self doItInContextName.</div>
<div><br></div><div>I&#39;m not sure how to fix this.  One way is for the above loop to encode &#39;ThisContext&#39; as &#39;ThisContext tempAt: 0&#39;, but that only works one level deep.  Once one has an m3 it will access the wrong ThisContext, but it&#39;ll be better than the current situation as there will be no exception.</div>
<div>    </div><div class="gmail_quote">On Tue, Jul 26, 2011 at 7:02 AM, Stéphane Ducasse <span dir="ltr">&lt;<a href="mailto:Stephane.Ducasse@inria.fr" target="_blank">Stephane.Ducasse@inria.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys<br>
<br>
I was debugging some bug and I got the following<br>
<br>
<br>
DoItIn: ThisContext<br>
        ^ self<br>
                do: [:each | ((ThisContext namedTempAt: 1)<br>
                                        includes: each)<br>
                                ifFalse: [^ false]]<br>
<br>
<br>
I selected (ThisContext namedTempAt: 1<br>
<br>
and I got MessageAsTempNode does not understand beMethodArg<br>
<br>
method: doit context: ctxt<br>
        &quot; pattern [ | temporaries ] block =&gt; MethodNode.&quot;<br>
<br>
        | sap blk prim temps messageComment methodNode |<br>
        properties := AdditionalMethodState new.<br>
        sap := self pattern: doit inContext: ctxt.<br>
        &quot;sap={selector, arguments, precedence}&quot;<br>
        properties selector: (sap at: 1).<br>
        encoder selector: (sap at: 1).<br>
        (sap at: 2) do: [:argNode | argNode beMethodArg].<br>
                                                ^^^^<br>
        doit ifFalse: [self pragmaSequence].<br>
        temps := self temporaries.<br>
        messageComment := currentComment.<br>
        currentComment := nil.<br>
        doit ifFalse: [self pragmaSequence].<br>
        prim := self pragmaPrimitives.<br>
        self statements: #() innerBlock: doit.<br>
        blk := parseNode.<br>
        doit ifTrue: [blk returnLast]<br>
                ifFalse: [blk returnSelfIfNoOther: encoder].<br>
        hereType == #doIt ifFalse: [^self expected: &#39;Nothing more&#39;].<br>
        self interactive ifTrue: [self removeUnusedTemps].<br>
        methodNode := self newMethodNode comment: messageComment.<br>
        ^methodNode<br>
                selector: (sap at: 1)<br>
                arguments: (sap at: 2)<br>
                precedence: (sap at: 3)<br>
                temporaries: temps<br>
                block: blk<br>
                encoder: encoder<br>
                primitive: prim<br>
                properties: properties<br>
<br>
<br>
argNode is a MessageAsTempNode and beMethodArg is only defined on TempVariableNode<br>
<br>
<br>
<a href="http://code.google.com/p/pharo/issues/detail?id=4551" target="_blank">http://code.google.com/p/pharo/issues/detail?id=4551</a><br>
<br>
Stef<br>
<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><br>
</div>