When simulating (for example via the debugger) correctly unwind the simulation machinery #ensure: block inserted by #runUntilErrorOrReturnFrom:
Simulating #aboutToReturn:through: did jump to first unwind context. But this first unwind context was determined BEFORE the simulation #ensure: has been inserted. This had the effect of skipping the simulation machinery protection, and did result in a BlockCannotReturn (cannotReturn:) error...
This did prevent the debugger to correctly debug a protected block with non local return like this:
[^2] ensure: [Transcript cr; show: 'done'].
Kudos to Jaromir for finding this!
=============== Diff against Kernel-jar.1406 ===============
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"
Item was added:
+ ----- Method: Context>>simulatedAboutToReturn:through: (in category 'private') -----
+ simulatedAboutToReturn: result through: firstUnwindContext
+ "This is the simulated version of #aboutToReturn:through:
+ Since the simulation machinery inserts its own ensure: block, we must unwind it first.
+ See #runUntilErrorOrReturnFrom:"
+ self methodReturnContext
+ return: result
+ through: ((thisContext findNextUnwindContextUpTo: firstUnwindContext) ifNil: [firstUnwindContext])!