unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6416: next-error mis-highlights ocaml error message locations
@ 2010-06-13 18:26 Jacques Le Normand
  2010-06-13 22:46 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques Le Normand @ 2010-06-13 18:26 UTC (permalink / raw)
  To: 6416

[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]

Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

if I compile the following with ocamlc:

let foo : int =
  "foo"
  ^
    "bar"

it gives me the error

File "/home/palomer/temp/test.ml", line 2, characters 1-21:
...

which refers to:
  "foo"
  ^
    "bar"

next-error will try and highlight characters 1 to 21 on line 2. however,
line 2 only contains 10 or so characters. This is because character 21
actually refers to character 8 on line 4. Instead of highlighting 3 lines,
only 1 line is highlighted.


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/22.2/etc/DEBUG for instructions.


In GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2010-03-29 on palmer, modified by Ubuntu
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
configured using `configure  '--build=i486-linux-gnu'
'--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim'
'--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars'
'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN
-DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed'
'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_CA.utf8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Tuareg

Minor modes in effect:
  shell-dirtrack-mode: t
  xterm-mouse-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  abbrev-mode: t

[-- Attachment #2: Type: text/html, Size: 3703 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6416: next-error mis-highlights ocaml error message locations
  2010-06-13 18:26 bug#6416: next-error mis-highlights ocaml error message locations Jacques Le Normand
@ 2010-06-13 22:46 ` Stefan Monnier
  2010-06-13 23:31   ` Jacques Le Normand
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-06-13 22:46 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: 6416

> let foo : int =
>   "foo"
>   ^
>     "bar"

> it gives me the error

> File "/home/palomer/temp/test.ml", line 2, characters 1-21:
> ...

> which refers to:
>   "foo"
>   ^
>     "bar"

How does 1-21 refer to that, exactly?  The first " seems to be either at
position 2 or 3 depending on whether you start counting at 0 or 1, so
how can it be 1-21 rather than 2-<something>?

Second, the 1-21 range refers to bytes in the file, right?  (i.e. does
it count a TAB as 1 or as 8? how about a CR+LF?).

> next-error will try and highlight characters 1 to 21 on line 2. however,
> line 2 only contains 10 or so characters. This is because character 21
> actually refers to character 8 on line 4. Instead of highlighting 3 lines,
> only 1 line is highlighted.

Indeed, it's on purpose: I've never heard of a format of error messages
of a form like the one you describe, so compile.el makes no attempt to
handle such things, AFAIK.  Usually error messages that can refer to
several lines take a form like "LINE.COL - LINE'.COL'" or something like
that where the end-line is specified explicitly.

So in the present case, compile.el guesses that the 21 is really an
error (maybe because it refers to some other version of the file or
something) and just stops the line's end.  This behavior is The Right
Thing for most tools where such errors can never span multiple lines.

The questions above would help us figure out how to best adjust
compile.el and compilation-regexp-error-alist to handle such errors
correctly.  Of course, the better solution would be to change OCaml so
as to use more standard error messages, such as the GNU format, so it
would "just work".  So I suggest you also file a bug-report to the OCaml
guys that their error messages use a non-standard format and are
confusing since they only say "line 2, chars 1-21" even for a message
that spans lines 2-4.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6416: next-error mis-highlights ocaml error message locations
  2010-06-13 22:46 ` Stefan Monnier
@ 2010-06-13 23:31   ` Jacques Le Normand
  2010-06-14 13:23     ` Stefan Monnier
  2021-08-26 18:30     ` Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: Jacques Le Normand @ 2010-06-13 23:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6416

[-- Attachment #1: Type: text/plain, Size: 2740 bytes --]

I apologize, the numbers in the example were erroneous. Take this example
instead:

let foo: int =
  "foo"
  ^
    "bar"

gives the error:
File "/home/palomer/temp/test.ml", line 2, characters 2-21:


ocamlc starts counting at 0. it counts newlines and tabs as 1. I obtained
these results empirically.  The previous example means:
"the third character from the start of line 2 to the 22nd character from the
start of line 2"

I've filed a bug report with ocaml developers (and have even suggested a
simple fix.) I can't say how inclined they will be to fix it. The bug id
is 0005070. The mantis url is http://caml.inria.fr/mantis/

thank you for your quick response,
-- Jacques

On Sun, Jun 13, 2010 at 6:46 PM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > let foo : int =
> >   "foo"
> >   ^
> >     "bar"
>
> > it gives me the error
>
> > File "/home/palomer/temp/test.ml", line 2, characters 1-21:
> > ...
>
> > which refers to:
> >   "foo"
> >   ^
> >     "bar"
>
> How does 1-21 refer to that, exactly?  The first " seems to be either at
> position 2 or 3 depending on whether you start counting at 0 or 1, so
> how can it be 1-21 rather than 2-<something>?
>
> Second, the 1-21 range refers to bytes in the file, right?  (i.e. does
> it count a TAB as 1 or as 8? how about a CR+LF?).
>
> > next-error will try and highlight characters 1 to 21 on line 2. however,
> > line 2 only contains 10 or so characters. This is because character 21
> > actually refers to character 8 on line 4. Instead of highlighting 3
> lines,
> > only 1 line is highlighted.
>
> Indeed, it's on purpose: I've never heard of a format of error messages
> of a form like the one you describe, so compile.el makes no attempt to
> handle such things, AFAIK.  Usually error messages that can refer to
> several lines take a form like "LINE.COL - LINE'.COL'" or something like
> that where the end-line is specified explicitly.
>
> So in the present case, compile.el guesses that the 21 is really an
> error (maybe because it refers to some other version of the file or
> something) and just stops the line's end.  This behavior is The Right
> Thing for most tools where such errors can never span multiple lines.
>
> The questions above would help us figure out how to best adjust
> compile.el and compilation-regexp-error-alist to handle such errors
> correctly.  Of course, the better solution would be to change OCaml so
> as to use more standard error messages, such as the GNU format, so it
> would "just work".  So I suggest you also file a bug-report to the OCaml
> guys that their error messages use a non-standard format and are
> confusing since they only say "line 2, chars 1-21" even for a message
> that spans lines 2-4.
>
>
>        Stefan
>

[-- Attachment #2: Type: text/html, Size: 3692 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6416: next-error mis-highlights ocaml error message locations
  2010-06-13 23:31   ` Jacques Le Normand
@ 2010-06-14 13:23     ` Stefan Monnier
  2021-08-26 18:30     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2010-06-14 13:23 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: 6416

> I apologize, the numbers in the example were erroneous. Take this example
> instead:
[...]
> File "/home/palomer/temp/test.ml", line 2, characters 2-21:

Thanks, that makes more sense.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6416: next-error mis-highlights ocaml error message locations
  2010-06-13 23:31   ` Jacques Le Normand
  2010-06-14 13:23     ` Stefan Monnier
@ 2021-08-26 18:30     ` Lars Ingebrigtsen
  2021-09-23 21:55       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-26 18:30 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: 6416, Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

Jacques Le Normand <rathereasy@gmail.com> writes:

> I apologize, the numbers in the example were erroneous. Take this example
> instead:
>
> let foo: int = 
>   "foo"
>   ^
>     "bar"
>
> gives the error:
> File "/home/palomer/temp/test.ml", line 2, characters 2-21:
>
> ocamlc starts counting at 0. it counts newlines and tabs as 1. I obtained these
> results empirically.  The previous example means:
> "the third character from the start of line 2 to the 22nd character from the
> start of line 2"
>
> I've filed a bug report with ocaml developers (and have even suggested a
> simple fix.) I can't say how inclined they will be to fix it. The bug id is
> 0005070. The mantis url is http://caml.inria.fr/mantis/

(I'm going through old bug reports that unfortunately weren't
resolved at the time.)

I'm not very familiar with ocaml, but I tried this recipe in Emacs 28 on
Debian/bullseye (so I guess a pretty new ocamlc), and it seems like it's
doing the right thing now?


[-- Attachment #2: Type: image/png, Size: 34363 bytes --]

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]


Is this working as expected now?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#6416: next-error mis-highlights ocaml error message locations
  2021-08-26 18:30     ` Lars Ingebrigtsen
@ 2021-09-23 21:55       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-23 21:55 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: 6416, Stefan Monnier

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I'm not very familiar with ocaml, but I tried this recipe in Emacs 28 on
> Debian/bullseye (so I guess a pretty new ocamlc), and it seems like it's
> doing the right thing now?
>
>
>
> Is this working as expected now?

More information was requested, but no response was given within a
month, so I'm closing this bug report.  If the problem still exists,
please respond to this email and we'll reopen the bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-23 21:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-13 18:26 bug#6416: next-error mis-highlights ocaml error message locations Jacques Le Normand
2010-06-13 22:46 ` Stefan Monnier
2010-06-13 23:31   ` Jacques Le Normand
2010-06-14 13:23     ` Stefan Monnier
2021-08-26 18:30     ` Lars Ingebrigtsen
2021-09-23 21:55       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).