UndeclaredVariable correction raises Error in Parser

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

UndeclaredVariable correction raises Error in Parser

Christoph Thiede

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



parser bug.1.cs (1K) Download Attachment
Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: UndeclaredVariable correction raises Error in Parser

Christoph Thiede

Hi all,


any chance to fix this until 5.3? Could anyone review the attached changeset? It only patches three methods :)


Best,

Christoph


Von: Thiede, Christoph
Gesendet: Samstag, 14. September 2019 00:47:41
An: The general-purpose Squeak developers list
Betreff: UndeclaredVariable correction raises Error in Parser
 

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


Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: UndeclaredVariable correction raises Error in Parser

Christoph Thiede
Hi all,

nine months later here is another friendly bump of this tiny patch. It would
be really great if someone could spend some minutes on reviewing and merging
it! :-)

Best,
Christoph



--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html

Carpe Squeak!