Skip to content
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

Closed
vicuna opened this issue Jul 31, 2013 · 5 comments
Closed

Error messages default to "line 1" #6112

vicuna opened this issue Jul 31, 2013 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jul 31, 2013

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

@vicuna
Copy link
Author

vicuna commented Jul 31, 2013

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.

@vicuna
Copy link
Author

vicuna commented Aug 1, 2013

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.

@vicuna
Copy link
Author

vicuna commented Aug 1, 2013

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.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

@rp Can you please submit a Github pull request if you would like to move this forward?

@vicuna
Copy link
Author

vicuna commented Feb 17, 2017

Comment author: @damiendoligez

This will very probably be obsoleted by #948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant