[squeak-dev] UndeclaredVariable correction raises Error in Parser

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Fri Sep 13 22:47:41 UTC 2019


Hi all,


maybe someone has time and knowledge to fix the following bug?


Scenario:

Try to compile the following method:


foo

    ba := nil.

42 ifNotNil: [:ba | ba].

Then accept it and answer the UndeclaredVariable dialog with 'declare temp variable'.

Expected behavior:

The method should be corrected to:


foo

  | ba |

    ba := nil.

    42 ifNotNil: [: "Name already used in this method ->"ba | ba].

Actual behavior:
UndeclaredVariableNode>>#sizeCodeForStorePop: is called and raises a #shouldNotImplement.

Interpretation:
I guess the problem is in #undeclaredTemps, where the encoder does not declare ba which was shadowed by the declaration in the block. How could that be solved? My first approach would be to store all UndeclaredTempVars in #bindUndeclaredTemp: separately, but I'm quite sure this is not efficient ... How would you solve this problem the best way?
However, I attached a change set for my attempt, all tests are green.

I'm excited to hear your answers! :)

Best,
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190913/afa8e3be/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parser bug.1.cs
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190913/afa8e3be/attachment.ksh>


More information about the Squeak-dev mailing list