[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/tuareg c6c49d4 08/10: Compensate for end-columns in OCaml
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/tuareg c6c49d4 08/10: Compensate for end-columns in OCaml messages being off by one |
Date: |
Fri, 30 Jul 2021 16:57:27 -0400 (EDT) |
branch: elpa/tuareg
commit c6c49d4fb654bd6dc69a0220cec731172a0c6a01
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>
Compensate for end-columns in OCaml messages being off by one
OCaml messages use exclusive end columns but Emacs expects them to
be inclusive. In other words, when OCaml says "characters 23-45",
tell Emacs to use columns 23..44, zero-based.
To complicate matters, Emacs 27 and earlier had an off-by-one bug
in the end-column function call code that we need for compensate for.
---
tuareg-tests.el | 38 +++++++++++++++++++-------------------
tuareg.el | 11 ++++++++++-
2 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/tuareg-tests.el b/tuareg-tests.el
index a4c6673..095a007 100644
--- a/tuareg-tests.el
+++ b/tuareg-tests.el
@@ -396,17 +396,17 @@ Returns the value of the last FORM."
'((("File \"file.ml\", line 4, characters 6-7:\n"
"Error: This expression has type int\n"
"This is not a function; it cannot be applied.\n")
- ((1 error "file.ml" 4 4 6 7)))
+ ((1 error "file.ml" 4 4 6 6)))
(("File \"file.ml\", line 3, characters 6-7:\n"
"Warning 26: unused variable y.\n")
- ((1 warning "file.ml" 3 3 6 7)))
+ ((1 warning "file.ml" 3 3 6 6)))
(("File \"helloworld.ml\", line 2, characters 36-64:\n"
"2 | module rec A: sig type t += A end = struct type t += A = B.A end\n"
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
"Error: Cannot safely evaluate the definition of the following cycle\n"
" of recursively-defined modules: A -> B -> A.\n")
- ((1 error "helloworld.ml" 2 2 36 64)))
+ ((1 error "helloworld.ml" 2 2 36 63)))
(("File \"helloworld.ml\", lines 4-7, characters 6-3:\n"
"4 | ......struct\n"
"5 | module F(X:sig end) = struct end\n"
@@ -414,7 +414,7 @@ Returns the value of the last FORM."
"7 | end\n"
"Error: Cannot safely evaluate the definition of the following cycle\n"
" of recursively-defined modules: A -> B -> A.\n")
- ((1 error "helloworld.ml" 4 7 6 3)))
+ ((1 error "helloworld.ml" 4 7 6 2)))
(("File \"robustmatch.ml\", lines 33-37, characters 6-23:\n"
" 9 | ......match t1, t2, x with\n"
"10 | | AB, AB, A -> ()\n"
@@ -424,7 +424,7 @@ Returns the value of the last FORM."
"Warning 8: this pattern-matching is not exhaustive.\n"
"Here is an example of a case that is not matched:\n"
"(AB, MAB, A)\n")
- ((1 warning "robustmatch.ml" 33 37 6 23)))
+ ((1 warning "robustmatch.ml" 33 37 6 22)))
(("File \"robustmatch.ml\", lines 33-37, characters 6-23:\n"
" 9 | ......match t1, t2, x with\n"
"10 | | AB, AB, A -> ()\n"
@@ -434,7 +434,7 @@ Returns the value of the last FORM."
"Warning 8 [partial-match]: this pattern-matching is not exhaustive.\n"
"Here is an example of a case that is not matched:\n"
"(AB, MAB, A)\n")
- ((1 warning "robustmatch.ml" 33 37 6 23)))
+ ((1 warning "robustmatch.ml" 33 37 6 22)))
(("File \"main.ml\", line 13, characters 34-35:\n"
"13 | let f : M.t -> M.t = fun M.C -> y\n"
" ^\n"
@@ -444,32 +444,32 @@ Returns the value of the last FORM."
" Definition of module M/1\n"
" File \"main.ml\", line 7, characters 0-32:\n"
" Definition of module M/2\n")
- ((1 error "main.ml" 13 13 34 35)
- (225 error "main.ml" 10 10 2 41)
- (308 error "main.ml" 7 7 0 32)))
+ ((1 error "main.ml" 13 13 34 34)
+ (225 error "main.ml" 10 10 2 40)
+ (308 error "main.ml" 7 7 0 31)))
(("Fatal error: exception Bad.Disaster(\"oh no!\")\n"
"Raised at file \"bad.ml\", line 5, characters 4-22\n"
"Called from file \"worse.ml\" (inlined), line 9, characters 2-5\n"
"Called from file \"worst.ml\", line 12, characters 8-18\n")
- ((47 error "bad.ml" 5 5 4 22)
- (96 error "worse.ml" 9 9 2 5)
- (158 error "worst.ml" 12 12 8 18)))
+ ((47 error "bad.ml" 5 5 4 21)
+ (96 error "worse.ml" 9 9 2 4)
+ (158 error "worst.ml" 12 12 8 17)))
(("Fatal error: exception Bad.Disaster(\"oh no!\")\n"
"Raised at Bad.f in file \"bad.ml\", line 5, characters 4-22\n"
"Called from Bad.g in file \"worse.ml\" (inlined), line 9, characters
2-5\n"
"Called from Bad in file \"worst.ml\", line 12, characters 8-18\n")
- ((47 error "bad.ml" 5 5 4 22)
- (105 error "worse.ml" 9 9 2 5)
- (176 error "worst.ml" 12 12 8 18)))
+ ((47 error "bad.ml" 5 5 4 21)
+ (105 error "worse.ml" 9 9 2 4)
+ (176 error "worst.ml" 12 12 8 17)))
(("Fatal error: exception Hell\n"
"Raised by primitive operation at Murky.depths in file \"inferno.ml\",
line 399, characters 28-54\n"
"Called from Nasty.f in file \"nasty.ml\", line 7, characters 13-40\n"
"Re-raised at Smelly.f in file \"smelly.ml\", line 14, characters
12-19\n"
"Called from Rubbish.g in file \"rubbish.ml\", line 17, characters
2-5\n")
- ((29 error "inferno.ml" 399 399 28 54)
- (124 error "nasty.ml" 7 7 13 40)
- (189 error "smelly.ml" 14 14 12 19)
- (258 error "rubbish.ml" 17 17 2 5))))
+ ((29 error "inferno.ml" 399 399 28 53)
+ (124 error "nasty.ml" 7 7 13 39)
+ (189 error "smelly.ml" 14 14 12 18)
+ (258 error "rubbish.ml" 17 17 2 4))))
"Compilation message test data.
Each element is (STRINGS ERRORS) where
diff --git a/tuareg.el b/tuareg.el
index 9e3b243..4f92def 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -3186,10 +3186,19 @@ Short cuts for interactions with the REPL:
"Regular expression matching the error messages produced by ocamlc/ocamlopt.
Also matches source references in exception backtraces.")
+(defun tuareg--end-column ()
+ "Return the end-column number in a parsed OCaml message.
+OCaml uses exclusive end-columns but Emacs wants them to be inclusive."
+ (and (match-beginning 7)
+ (+ (string-to-number (match-string 7))
+ ;; Prior to Emacs 28, the end-column function value was incorrectly
+ ;; off by one.
+ (if (>= emacs-major-version 28) -1 0))))
+
(when (boundp 'compilation-error-regexp-alist-alist)
(setq compilation-error-regexp-alist-alist
(assq-delete-all 'ocaml compilation-error-regexp-alist-alist))
- (push `(ocaml ,tuareg--error-regexp 3 (4 . 5) (6 . 7) (8) 1
+ (push `(ocaml ,tuareg--error-regexp 3 (4 . 5) (6 . tuareg--end-column) (8) 1
(8 font-lock-function-name-face))
compilation-error-regexp-alist-alist))
- [nongnu] elpa/tuareg updated (b59c422 -> 465b61f), ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 64fada7 01/10: Rewrite `tuareg--error-regexp` in rx, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg b4d09cd 03/10: Remove duplicates from compilation-error-regexp-alist{-alist}, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 8c8d217 05/10: Simpler matching of ending line and character in compiler message, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg c6c49d4 08/10: Compensate for end-columns in OCaml messages being off by one,
ELPA Syncer <=
- [nongnu] elpa/tuareg a06468c 09/10: Repair handling of ocamldoc section headers like {2:text}, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 465b61f 10/10: Merge commit 'refs/pull/258/head' of github.com:/ocaml/tuareg into elpa/tuareg, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 00c4cf8 06/10: Match source locations in exception backtraces, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 0f49e65 02/10: Only fontify known @-tags in doc-markup face, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg aa57258 04/10: Recognise new warning format in compilation output, ELPA Syncer, 2021/07/30
- [nongnu] elpa/tuareg 916c551 07/10: Add ERT test of compilation and backtrace messages, ELPA Syncer, 2021/07/30