[Cuis-dev] A bug in handling nested #outer exceptions
Jaromir Matas
mail at jaromir.net
Sun May 2 10:28:07 PDT 2021
Hi,
I’d like to report a bug in how Cuis handles nested #outer exceptions. Try the following example:
path := ''.
[path := path, '1'.
[path := path, '2'.
[1/0] on: ZeroDivide do: [:ex | ex outer. path := path, '5'. ex return].
path := path, '6'
] on: ZeroDivide do: [:ex | ex outer. path := path, '4'. ex resume].
path := path, '7'
] on: ZeroDivide do: [:ex | path := path, '3'. ex resume].
path
Currently it answers '12345' which means points 6 and 7 have been missed. The reason is incorrect handling of saved handlerContexts. I tried to fix the current Cuis implementation using a collection handlerContexts but I’m not sure it’s possible. I can’t even figure out what was the handlerContexts collection intended for (please let me know if I’ve missed it). Current handler contexts can be easily tracked by using a temporary variable in #outer and retrieved back in #resumeUnchecked – see the enclosed changeset illustrating the idea. In case the handlerContexts collection has no other (real or intended) use then it could be replaced by a simple handlerContext variable containing the handler of the exception being currently dealt with and the two ugly lines would be replaced by:
+ handlerContext _ ctxt tempAt: 2. "currHandlerContext in #outer"
- self popHandlerContext. "update the top context with the #outer handler"
- self pushHandlerContext: (ctxt tempAt: 2). "currHandlerContext in #outer"
Best regards,
Jaromir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210502/82847e09/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4568-CuisCore-JaromirMatas-2021May02-18h54m-jar.001.cs.st
Type: application/octet-stream
Size: 1207 bytes
Desc: 4568-CuisCore-JaromirMatas-2021May02-18h54m-jar.001.cs.st
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210502/82847e09/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BaseImageTests-jar.001.cs.st
Type: application/octet-stream
Size: 530 bytes
Desc: BaseImageTests-jar.001.cs.st
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210502/82847e09/attachment-0001.obj>
More information about the Cuis-dev
mailing list