-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Error message shows wrong source text with preprocessor #12238
Description
I'm using OCaml 4.11.1 on Debian/amd64.
If a (text-based) preprocessor heads its output with a #line directive, then compiler error messages show the correct line and char numbers, but the echo of the source text shown next to them is wrong. For example, try compiling the attached file foo.ml using the trivial preprocessor trivpp, a shell script that just prepends a #line directive.
ocamlc -c -pp trivpp foo.ml
The result is the following error message:
File "foo.ml", line 100, characters 8-11:
99 | ..
100 | ..... = .
Error: This expression has type int
This is not a function; it cannot be applied.
The line number is correct, but the echo of the source is garbled.
Interestingly, deleting all the input text after the line with the error results in a correct display of the relevant source code.
(I am not using this trivial preprocessor, but another one that implements certain constructs by textual expansion. For files that don't contain instances of the constructs, its effect is the same as the trivial preprocessor, however.)