Fergus Henderson wrote:

> On 19-Dec-1997, Simon L Peyton Jones <[EMAIL PROTECTED]> wrote:
> >
> > I thought you might find the following bug I've just
> > found in GHC entertaining.

...

> >       sameVal (AbsApproxFun str1 v1) (AbsApproxFun str2 v2)
> >               = str1 == str2 && sameVal v1 v1

...

> This bug could have been caught by a very simple static analysis that
> is very popular in the logic programming community: singleton variable
> warnings.  In the code above, the variable `v2' occurs only once.
> Singleton variables such as this are often bugs.  For cases where the
> programmer really does want a singleton variable, the warning can be
> suppressed by using a different naming convention (in Prolog, it
> would be `_v2'; since Haskell doesn't allow leading underscores,
> I suppose you could use `v2_').

In this case, the even simpler ``unused identifier'' warning would suffice!
(Easily suppressed by the use of a wildcard pattern such as `_'.)

> So, sing ho for regression tests, but sing louder for static analysis ;-)

Hear, hear!


Merry Xmas, etc.,

   David Bruce
----
post: DERA Malvern, St Andrews Road, Malvern, WORCS WR14 3PS, ENGLAND
mailto:[EMAIL PROTECTED] ** phone: +44 1684 895112 ** fax: +44 1684 894389

[The views expressed above are entirely those of the writer and do not represent the 
views, policy or understanding of any other person or official body.]



Reply via email to