New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error messages default to "line 1" #6112
Comments
Comment author: @gasche 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. |
Comment author: @xavierleroy 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. |
Comment author: rp 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. |
Comment author: @mshinwell @rp Can you please submit a Github pull request if you would like to move this forward? |
Comment author: @damiendoligez This will very probably be obsoleted by #948 |
Original bug ID: 6112
Reporter: rp
Status: resolved (set by @damiendoligez on 2017-02-17T15:13:39Z)
Resolution: suspended
Priority: normal
Severity: tweak
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Bug 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.
File attachments
The text was updated successfully, but these errors were encountered: