[PATCH] bugfix for Promise >> printOn:

Tommy Pettersson <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <20170414202655.GA17907@kelsos>
Hi list,

I just subscribed, and this is my first post to the list.

The class Promise has a bug in printOn:. It is supposed to print '(???)' if
its value is not yet known. A missing return causes it to continue to print
the actual value, which will hang until the value is known. Same problem if
Promise has an error.

Here's a trivial patch.

/Tommy


diff --git a/kernel/ValueAdapt.st b/kernel/ValueAdapt.st
index d2957fd..95bdfb0 100644
--- a/kernel/ValueAdapt.st
+++ b/kernel/ValueAdapt.st
@@ -262,8 +262,8 @@ initialized, I suspend the process until a value has been assigned.'>
 
 	<category: 'printing'>
 	aStream print: self class.
-	self hasValue ifFalse: [ aStream nextPutAll: '(???)' ].
-	self hasError ifTrue: [ aStream nextPutAll: '(Error!)' ].
+	self hasValue ifFalse: [ ^aStream nextPutAll: '(???)' ].
+	self hasError ifTrue: [ ^aStream nextPutAll: '(Error!)' ].
 
 	aStream
 	    nextPut: $(;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.