Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] assert + -pp = wrong line number and filename in assert message
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] assert + -pp = wrong line number and filename in assert message
> The "assert" construct generates an exception which contains the file
> name and line number where the "assert" appears.

Character number, actually.

> However, when a preprocessor is used (with the -pp option), the file name
> and line number that are recorded are relative to the preprocessor
> output file and not to original source file, even when the 
> '# linenum "filename"' directives are inserted in the preprocessor
> output.

Right.  OCaml has a peculiar way of treating positions in source code:
on parsing, it remembers minimal information (absolute character
numbers in the input, regardless of # lineno "filename" directives),
and it's only when an error is detected that it re-scans the input to
convert the character numbers into file name + line number.

This works well for error reporting, but causes problems with
"assert", the compiler-generated "Match_failure" exceptions, and
certain uses of Camlp4.

All this will have to be addressed at some point, although it's rather
painful to do right.

Best regards,

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr