[Cuis-dev] [bug?] Decompiler does not restore unused temporary variables
Juan Vuletich
juan at cuis.st
Mon May 5 09:12:50 PDT 2025
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
> <mailto: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 Vuletich
> www.cuis-smalltalk.org <http://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
>
>
>
> --
>
> Nicolás Papagna
--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250505/2eb11dce/attachment-0001.htm>
More information about the Cuis-dev
mailing list