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

Juan Vuletich juan at cuis.st
Mon May 5 08:54:15 PDT 2025


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 Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
https://independent.academia.edu/JuanVuletich
https://www.researchgate.net/profile/Juan-Vuletich
https://patents.justia.com/inventor/juan-manuel-vuletich
https://twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250505/629542ae/attachment.htm>


More information about the Cuis-dev mailing list