Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006112OCamlOCaml generalpublic2013-07-31 21:012016-04-14 17:14
Assigned To 
PlatformOSOS Version
Product Version 
Target Version4.03.1+devFixed in Version 
Summary0006112: Error messages default to "line 1"
DescriptionWhen 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
let a () = 3
let b () = 4
let c () = a(); b()
$ ocamlc -warn-error A
File "", line 4, characters 11-14:
Warning 10: this expression should have type unit.
File "", line 1:
Error: Error-enabled warnings (1 occurrences)
Additional InformationThe 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.
Attached Filesdiff file icon no-dummy-line-in-error-messages.diff [^] (7,200 bytes) 2013-07-31 21:01 [Show Content]
diff file icon no-dummy-line-in-warning-enabled-error-messages.diff [^] (2,004 bytes) 2013-08-01 11:58 [Show Content]

- Relationships

-  Notes
gasche (developer)
2013-07-31 21:23

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.
xleroy (administrator)
2013-08-01 09:27

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.
rp (reporter)
2013-08-01 12:02

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.

- Issue History
Date Modified Username Field Change
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
2014-01-17 17:41 doligez Tag Attached: patch
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-16 20:37 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-22 21:50 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-02-25 23:31 doligez Target Version 4.02.2+dev / +rc1 => 4.03.0+dev / +beta1
2016-04-14 17:14 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker