* [Caml-list] assert + -pp = wrong line number and filename in assert message
@ 2001-08-23 16:28 Paul Stodghill
2001-08-23 16:59 ` Paul Stodghill
2001-08-28 7:31 ` Xavier Leroy
0 siblings, 2 replies; 3+ messages in thread
From: Paul Stodghill @ 2001-08-23 16:28 UTC (permalink / raw)
To: caml-list
The "assert" construct generates an exception which contains the file
name and line number where the "assert" appears.
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.
A quick scanner of ocaml-3.02/parsing/lexer.mll seems to indicate that
the line directive is completely ignored.
milhouse$ uname -a
CYGWIN_NT-5.0 MILHOUSE 1.3.2(0.39/3/2) 2001-05-20 23:28 i686 unknown
milhouse$ ocamlc -v
The Objective Caml compiler, version 3.02
Standard library directory: /usr/local/lib/ocaml
milhouse$
milhouse$
milhouse$ cat preproc.sh
#! /bin/sh
echo '# 1 "'$1'"'
cat $1
milhouse$
milhouse$
milhouse$ cat assert_bug.ml
assert false;;
milhouse$
milhouse$
milhouse$ ocamlc -o assert_bug.exe -pp './preproc.sh' assert_bug.ml
milhouse$ ./assert_bug.exe
Fatal error: uncaught exception Assert_failure("/home/stodghil/tmp/camlpp0", 20, 32)
milhouse$
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] assert + -pp = wrong line number and filename in assert message
2001-08-23 16:28 [Caml-list] assert + -pp = wrong line number and filename in assert message Paul Stodghill
@ 2001-08-23 16:59 ` Paul Stodghill
2001-08-28 7:31 ` Xavier Leroy
1 sibling, 0 replies; 3+ messages in thread
From: Paul Stodghill @ 2001-08-23 16:59 UTC (permalink / raw)
To: caml-list
> The "assert" construct generates an exception which contains the file
> name and line number where the "assert" appears.
> [ rest deleted ]
I should point out that the compiler does seem to respect '# line'
directives correctly when it comes to reporting syntax error. The
problem only appears to be with the assert construct.
milhouse$ cat bogus.ml
this is totally bogus
milhouse$ ocamlc -c -pp './preproc.sh' bogus.ml
File "bogus.ml", line 1, characters 0-4:
Unbound value this
milhouse$
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] assert + -pp = wrong line number and filename in assert message
2001-08-23 16:28 [Caml-list] assert + -pp = wrong line number and filename in assert message Paul Stodghill
2001-08-23 16:59 ` Paul Stodghill
@ 2001-08-28 7:31 ` Xavier Leroy
1 sibling, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 2001-08-28 7:31 UTC (permalink / raw)
To: Paul Stodghill; +Cc: caml-list
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-08-28 7:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-23 16:28 [Caml-list] assert + -pp = wrong line number and filename in assert message Paul Stodghill
2001-08-23 16:59 ` Paul Stodghill
2001-08-28 7:31 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).