[Cuis-dev] [bug?] Decompiler does not restore unused temporary variables

Hernán Wilkinson hernan.wilkinson at 10pines.com
Tue May 6 15:22:37 PDT 2025


Hi,
 attached is a change I propose to DecompilerTests (it should be called
DecompilerTest, singular, a change I did not include to facilitate merging).
 Currently DecompilerTests decompiles all classes in the image. This
contradicts a testing rule that is that "the test must be in control of
everything". In these tests, they do not control the setup because the
decompiled classes will change based on the classes in the image, that is
the reason Nico, me and for sure other people get a test failure when
running that test.
 To minimize the impact I changed the tests to run only on the base
classes, that is classes on Kernel, Graphics, System, etc.
 BTW, I don't know what DecompilerTestFailuresCollector is there for... it
has no tests and no references...

Cheers!
Hernan.

On Mon, May 5, 2025 at 1:13 PM Juan Vuletich via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> On 5/5/2025 1:04 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
>
> Hi Juan, all!
>
> Thanks for the clarification.
>
> CodeCoverage de-optimizes methods to do its thing, so CodeCoverageTest
> temporaryVariable is actually a valid use-case (it's used to check
> whether the temporary variable declaration is marked as 'covered' when the
> variable is read.
>
> Is there any way I can exclude such tests from DecompilerTests?
> I'm building a custom image where I need to check that I didn't break any
> tests in the base image and that failing tests is breaking my CI builds,
> preventing the build from suceeding.
>
> Cheers!
> Nico PM
>
>
> Yes, you can add it to #expectedFailures . BaseImageTests has some
> examples of this.
>
> Cheers,
>
>
> On Mon, May 5, 2025 at 12:54 PM Juan Vuletich <juan at cuis.st> wrote:
>
>> Hi Nico.
>>
>> I don't think this is a bug. Decompiler creates Smalltalk code from
>> actual bytecode. Dead code had been removed when generating the bytecode.
>> Looks fine to me.
>>
>> Does it make sense to add some use of the 'a' variable, so it is kept
>> during compilation? I mean, it is difficult to imagine that
>> CodeCoverageTest can do something interesting with a method that had all
>> its code optimized out...
>>
>> Cheers,
>>
>> On 5/4/2025 1:49 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
>>
>> Hi folks,
>>
>> I don't know if this is a bug or the expected behavior.
>>
>> Today I ran the tests in BaseImageTests with the CodeCoverage package (
>> https://github.com/npapagna/cuis-code-coverage) loaded and one of the
>> DecompilerTests failed.
>> The reason seems to be that Decompiler does not restore unused temporary
>> variables.
>>
>> In particular, DecompilerTests>>#testDecompilerInClassesCNtoCZ was
>> failing on CodeCoverageTest temporaryVariable:
>> (For context: this method is needed to reproduce a test scenario for the
>> CodeCoverage tool)
>>
>> CodeCoverageTest >> #temporaryVariable
>>     | a |
>>     a.
>>
>> To reproduce without the CodeCoverage package, evaluate:
>>
>> Object compile: 'm1 |a| a'.
>>
>> newCodeString := (Decompiler new
>>     decompile: #m1
>>     in: Object
>>     method: Object >> #m1) decompileString.
>>
>> Notice that newCodeString is 'm1 ^ self.' and it should be 'm1 |a| a'(if
>> this is really a bug).
>>
>> The code above was run on HEAD at the moment
>> (6c13d4eda2e9a8c56362ae3363d7b013917227c5).
>>
>> Is this something that needs to be fixed?
>>
>> Best,
>> Nico PM
>>
>>
>>
>> --
>> Juan Vuletichwww.cuis-smalltalk.orghttps://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Devhttps://github.com/jvuletichhttps://www.linkedin.com/in/juan-vuletich-75611b3https://independent.academia.edu/JuanVuletichhttps://www.researchgate.net/profile/Juan-Vuletichhttps://patents.justia.com/inventor/juan-manuel-vuletichhttps://twitter.com/JuanVuletich
>>
>>
>
> --
>
> Nicolás Papagna
>
>
>
> --
> Juan Vuletichcuis.stgithub.com/jvuletichresearchgate.net/profile/Juan-Vuletichindependent.academia.edu/JuanVuletichpatents.justia.com/inventor/juan-manuel-vuletichlinkedin.com/in/juan-vuletich-75611b3twitter.com/JuanVuletich
>
> --
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250506/7811de06/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UnsavedChangesTo-BaseImageTests-HAW.001.cs.st
Type: application/octet-stream
Size: 11190 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250506/7811de06/attachment-0001.obj>


More information about the Cuis-dev mailing list