[BUG][FIX] ifError: error blocks are often incorrect

Lex Spoon lex at cc.gatech.edu
Mon Jun 25 21:30:13 UTC 2001


mdr at scn.org (Mike Rutenberg) wrote:

> In 5 methods, people have coded natural but incorrect exception
> handling of the form
> 	[normalExpression] ifError: [errorResultExpression]
> The allowed form is presently only:
> 	[normalExpression] ifError: [ :err :rcvr | errorResultExpression]
> 
> For, example,
> 	ImageSegment>>copyFromRoots:sizeHint:areUnique:
> has the incorrect expression
> 	[outPointerArray _ Array new: segSize // 20] ifError: [
> 		state _ #tooBig.  ^ self].
> 
> Since the error block is not checked for the right number of arguments,
> this mistake will remain dormant until the error exception is actually
> taken.  A debugger will appear complaining that the block is being
> evaluated with the wrong number of arguments.
> 

IMHO, the much bigger problem is that there is code in the image that
has never been run!  Statement coverage will always flush out this
error, and statement coverage is a pretty minimal level of testing.

That said, I don't *mind* if ifError: does the check.


-Lex





More information about the Squeak-dev mailing list