[Cuis-dev] [bug?] Inconsistent source ranges for TemporariesDeclarationNode

Nicolás Papagna Maldonado nicolas.papagna at gmail.com
Thu Apr 3 05:38:13 PDT 2025


Hi folks!

I've found another case where source ranges are not computed as expected in
the presence of whitespace:

   1. git clone --depth=1
   https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev.git bug_repro
   (5a58b89c46457c6392f6952c6fc29af481a47654 at the time of reporting this bug)
   2. Open Cuis from that folder
   3. Open a workspace
   4. Evaluate Object compile: 'm1 1'.Print (Object >> #m1) methodNode
   rawSourceRanges.
   This outputs a Dictionary({1}->an OrderedCollection((3 to: 4)) )
   Notice the informed source range for the {1} node should be just one
   character (at position 4), not two.

Am I missing something?

Thanks!
Nico PM


On Wed, Mar 26, 2025 at 12:56 PM Hernán Wilkinson <
hernan.wilkinson at 10pines.com> wrote:

> I think it is a bug. I do not see why it should work that way...
> The problem is, is there code that relies on this behavior? and if so, how
> do we find it?
>
> On Wed, Mar 26, 2025 at 9:51 AM Nicolás Papagna Maldonado via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> Hi folks,
>>
>> I found out that the source ranges for temporaries declaration nodes are
>> sometimes computed differently:
>>
>>    1. git clone --depth=1
>>    https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev.git bug_repro
>>    2. Open Cuis from that folder
>>    3. Open a workspace
>>    4. Evaluate Object compile: 'm1 ||'Print (Object >> #m1) methodNode
>>    rawSourceRanges.
>>    This outputs a Dictionary({| |}->(4 to: 4) )
>>    Notice the informed source range for the temporaries declaration node
>>    is just one character (at position 4), not two.
>>    5. Evaluate Object compile: 'm1 || '
>>    Notice there is a space after ||Print (Object >> #m2) methodNode
>>    rawSourceRanges.
>>    This outputs a Dictionary({| |}->(4 to: 5) )
>>    Notice the informed source range is correct now.
>>
>> Even though I used a space at the end of the declaration in step 5, it
>> works for newlines too (In fact, that's how I found the bug in one of my
>> methods).
>>
>> I don't know if this bug affects the source ranges of other parse nodes.
>>
>> Cheers!
>> Nico PM
>> .
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
>
> --
>
> *Hernán WilkinsonAgile Software Development, Teaching & Coaching*
> *Phone: +54-011*-4893-2057
> *Twitter: @HernanWilkinson*
> *site: http://www.10Pines.com <http://www.10pines.com/>*
> Address: Alem 896, Floor 6, Buenos Aires, Argentina
>


-- 

Nicolás Papagna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250403/e77074a5/attachment.htm>


More information about the Cuis-dev mailing list