Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
line number in exception history?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-10-11 (09:09)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] line number in exception history?
> A student in Tokyo (_not_ CS major!) reported a "problem" (see below)
> of ocaml in his blog.  I guess it is because the line/character
> numbers point to the _head_ of the expression that _follows_ where the
> exception went through.  Is this a feature or a bug?

Your code is strange: you do realize that
     raise (invalid_arg "Give me positive!")
is weird because invalid_arg is a function that raises an exception itself?

Assuming that was intended, the backtrace is indeed slightly
inaccurate in two ways:

> Raised at file "", line 22, character 17

That is correct.

> Re-raised at file "", line 3, character 46

That should be "Called from file" but I guess the enclosing "raise"
confused the backtrace printer.

> Called from file "", line 3, character 2

This is indeed off by one line.  In general, the location following the
function call is reported, i.e

         function_that_raises arg1 arg2 arg3
                                            reported location

while in your example the following "in \n" is skipped.  Maybe one of
us will look at this, but I don't fell it's a big issue.

- Xavier Leroy