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

Nicolás Papagna Maldonado nicolas.papagna at gmail.com
Mon May 5 09:04:14 PDT 2025


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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250505/8accf47c/attachment.htm>


More information about the Cuis-dev mailing list