* Exceptions inside assertions
@ 1999-11-10 0:06 Gerd Stolpmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Stolpmann @ 1999-11-10 0:06 UTC (permalink / raw)
To: caml-list
Hi,
I have a problem with exceptions which are raised within the expression of an
assertion, e.g.
assert (raise Not_found)
The current behaviour is that the exception "falls through the assertion" which
may not be appropriate for some cases. For example, consider
assert (Queue.peek queue == current_element)
>From my point of view, the assertion expresses that "queue" has at least one
element and that this element is identical to "current_element". But if the
assertion is violated because the queue is empty, I only get a Queue.Empty
exception, and I do not see the reason for it. Perhaps I even catch
Queue.Empty, and the program continues, which is very hard to find out.
I suggest to introduce a new Assert_failure_by_exception exception to better
report this situation.
Gerd
--
----------------------------------------------------------------------------
Gerd Stolpmann Telefon: +49 6151 997705 (privat)
Viktoriastr. 100
64293 Darmstadt EMail: Gerd.Stolpmann@darmstadt.netsurf.de (privat)
Germany
----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Exceptions inside assertions
@ 1999-11-12 16:10 Damien Doligez
0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 1999-11-12 16:10 UTC (permalink / raw)
To: caml-list
>From: Gerd Stolpmann <Gerd.Stolpmann@darmstadt.netsurf.de>
>
>I have a problem with exceptions which are raised within the expression of an
>assertion, e.g.
>
>assert (raise Not_found)
>
>The current behaviour is that the exception "falls through the
>assertion" which may not be appropriate for some cases.
I'd say this is a bug: the doc says Assert_failure is raised whenever
the expression does not evaluate to true.
This will be fixed in the next release.
-- Damien
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-11-12 16:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-10 0:06 Exceptions inside assertions Gerd Stolpmann
1999-11-12 16:10 Damien Doligez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox