pharo-vm
pharo-vm copied to clipboard
Function returning void
By changing primitiveSuspend, I encountered this case.
process = self activeProcess ifTrue:
[self pop: 1 thenPush: objectMemory nilObject.
^self transferTo: self wakeHighestPriority].
I wanted to change the code to:
process = self activeProcess ifTrue:
[self pop: 1 thenPush: objectMemory nilObject.
self assertBlah.
returnOfTransferTo := self transferTo: self wakeHighestPriority.
self assertBloh.
^returnOfTransferTo
].
It translates to C but C cannot compile since the definition is void transferTo(sqInt proc) and returnOfTransferTo is sqInt. The correct code that replicate the first behavior in C is:
process = self activeProcess ifTrue:
[self pop: 1 thenPush: objectMemory nilObject.
self assertBlah.
self transferTo: self wakeHighestPriority.
self assertBloh.
^self
].
I did not try if the simulation works with version 2.
tl;dr: The Slang compiler should detect that #transferTo: returns a void. Assigning a void value to a variable does not make sense