[squeak-dev] The Inbox: Kernel-jar.1415.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Nov 20 11:22:44 UTC 2021

A new version of Kernel was added to project The Inbox:

==================== Summary ====================

Name: Kernel-jar.1415
Author: jar
Time: 20 November 2021, 12:22:39.046144 pm
UUID: 2058b1fd-425a-fa46-a2e0-297d1bfab952
Ancestors: Kernel-jar.1414

Fix a bug: when debugging things like this:

	[^2] ensure: [Transcript cr; show: 'done']

if we step into the protected block [^2] and then step over ^2, we incorrectly get a BlockCannotReturn error. 

This is an alternative proposal to Kernel-jar.1421 (and Kernel-jar.1413); the solution remains the same but it attempts to present a cleaner code (trying to address Christoph's objection in [2] and [3]).

The bug is described in detail in Kernel-nice.1407 and discussed in [1] and most recently in [2] and [3]:
[1] http://forum.world.st/stepping-over-non-local-return-in-a-protected-block-td5128777.html
[2] http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-August/216214.html
[3] http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-November/216971.html

=============== Diff against Kernel-jar.1414 ===============

Item was changed:
  ----- Method: Context>>resume:through: (in category 'controlling') -----
  resume: value through: firstUnwindCtxt
  	"Unwind thisContext to self and resume with value as result of last send.
  	 Execute any unwind blocks while unwinding.
  	 ASSUMES self is a sender of thisContext."
  	| ctxt unwindBlock |
  	self isDead ifTrue: [self cannotReturn: value to: self].
+ 	ctxt := firstUnwindCtxt value.	"evaluate in case firstUnwindCtxt is a block (used in simulation)"
- 	ctxt := firstUnwindCtxt ifNil: [thisContext findNextUnwindContextUpTo: self].
  	[ctxt isNil] whileFalse:
  		[(ctxt tempAt: 2) ifNil:
  			[ctxt tempAt: 2 put: true.
  			 unwindBlock := ctxt tempAt: 1.
  			 thisContext terminateTo: ctxt.
  			 unwindBlock value].
  		 ctxt := ctxt findNextUnwindContextUpTo: self].
  	thisContext terminateTo: self.

Item was changed:
  ----- Method: Context>>return:from: (in category 'instruction decoding') -----
  return: value from: aSender 
  	"For simulation.  Roll back self to aSender and return value from it.  Execute any unwind blocks on the way.  ASSUMES aSender is a sender of self"
  	| newTop |
  	aSender isDead ifTrue:
  		[^self send: #cannotReturn: to: self with: {value}].
  	newTop := aSender sender.
  	(self findNextUnwindContextUpTo: newTop) ifNotNil:
+ 		[^self send: #aboutToReturn:through: to: self with: {value. [thisContext findNextUnwindContextUpTo: newTop]}].
- 		[^self send: #aboutToReturn:through: to: self with: {value. nil}].
  	self releaseTo: newTop.
  	newTop ifNotNil: [newTop push: value].

More information about the Squeak-dev mailing list