pharo-vm icon indicating copy to clipboard operation
pharo-vm copied to clipboard

Function returning void

Open Alisu opened this issue 2 years ago • 1 comments

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.

Alisu avatar Nov 02 '21 16:11 Alisu

tl;dr: The Slang compiler should detect that #transferTo: returns a void. Assigning a void value to a variable does not make sense

hogoww avatar Nov 05 '21 08:11 hogoww