|Anonymous | Login | Signup for a new account||2013-12-05 07:56 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006112||OCaml||OCaml general||public||2013-07-31 21:01||2013-08-19 17:05|
|Target Version||4.01.1+dev||Fixed in Version|
|Summary||0006112: Error messages default to "line 1"|
|Description||When no line information is available, errors and warnings are reported on |
line 1. The attached patch modifies this behaviour: line-less errors can now
be printed without line numbers.
|Steps To Reproduce||$ cat error.ml|
let a () = 3
let b () = 4
let c () = a(); b()
$ ocamlc -warn-error A error.ml
File "error.ml", line 4, characters 11-14:
Warning 10: this expression should have type unit.
File "error.ml", line 1:
Error: Error-enabled warnings (1 occurrences)
|Additional Information||The approach taken involves an optional parameter which does not play |
particularly nice with the use of "%a" in the format strings. Suggestions for
a better approach welcome.
|Tags||No tags attached.|
|Attached Files|| no-dummy-line-in-error-messages.diff [^] (7,200 bytes) 2013-07-31 21:01 [Show Content]
no-dummy-line-in-warning-enabled-error-messages.diff [^] (2,004 bytes) 2013-08-01 11:58 [Show Content]
The (startchar >= 0) test is already used to inhibit printing of column position in presence of garbage information. Maybe you could simply change the in_file function so that it also use (-1) as the line number, and extend the print_loc tests to not print negative line numbers.
There may be backward-compatibility issues with modifying Location.in_file, but I had a quick look at the various occurrences in the compiler and it looks like they would benefit of this change -- to be checked more carefully again.
If I remember correctly, the spurious "line 1" was added so that Emacs would deign parse the error and at least open the incriminated file -- it would not do this with just a file name but no line number. Maybe Emacs's behavior changed since. But please let's avoid a regression here.
Also, I feel the patch would be less invasive if new functions print_file_location and print_file_error were introduced instead of this pesky optional argument.
New, less-intrusive patch.
The omission of (dummy) line number is only for error-enabled warnings. The (correct) location information is printed (and parsed by emacs) with the warning message.
|2013-07-31 21:01||rp||New Issue|
|2013-07-31 21:01||rp||File Added: no-dummy-line-in-error-messages.diff|
|2013-07-31 21:23||gasche||Note Added: 0010043|
|2013-08-01 09:27||xleroy||Note Added: 0010051|
|2013-08-01 09:27||xleroy||Status||new => feedback|
|2013-08-01 11:58||rp||File Added: no-dummy-line-in-warning-enabled-error-messages.diff|
|2013-08-01 12:02||rp||Note Added: 0010060|
|2013-08-01 12:02||rp||Status||feedback => new|
|2013-08-19 17:05||doligez||Status||new => confirmed|
|2013-08-19 17:05||doligez||Target Version||=> 4.01.1+dev|
|Copyright © 2000 - 2011 MantisBT Group|