branch: elpa/haskell-tng-mode commit 20c778571db5fe748b1baa944ba2bad47c3df94f Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
highlight ghc details in compile messages --- haskell-tng-compile.el | 14 ++++++++++++-- test/compile/ghc-9.2.7-details.compile | 17 +++++++++++++++++ test/compile/ghc-9.2.7-details.compile.faceup | 17 +++++++++++++++++ test/haskell-tng-compile-test.el | 3 +++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/haskell-tng-compile.el b/haskell-tng-compile.el index 20b8e56eab..fd62d57b98 100644 --- a/haskell-tng-compile.el +++ b/haskell-tng-compile.el @@ -26,12 +26,22 @@ :type 'booleanp :group 'haskell-tng) +;; c.f. compilation-error-regexp-alist +;; Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK HIGHLIGHT...]) (defvar haskell-tng-compilation-error-regexp-alist (let ((file '(: (group (+ (not (any "{" "}" "(" ")" "[" "]" "\n"))) ".hs"))) (num '(: (group (+ digit)))) (err '(: ": " (group "error") ":")) (war '(: ": " (group "warning") ":"))) - `(;; ghc errors / warnings (including -ferror-spans) + `(;; ghc details + (,(rx-to-string + `(: bol (+ not-newline) " is defined at " ,file ":" ,num ":" ,num (? "-" ,num))) + 1 2 (3 . 4) 0 1) + (,(rx-to-string + `(: bol (+ not-newline) " is defined at " ,file ":(" ,num "," ,num ")-(" ,num "," ,num ")")) + 1 (2 . 4) (3 . 5) 0 1) + + ;; ghc errors / warnings (including -ferror-spans) (,(rx-to-string `(: bol ,file ":" ,num ":" ,num (? "-" ,num) ,err)) 1 2 (3 . 4) 2 1 (5 'compilation-error)) (,(rx-to-string `(: bol ,file ":" ,num ":" ,num (? "-" ,num) ,war)) @@ -41,7 +51,7 @@ (,(rx-to-string `(: bol ,file ":(" ,num "," ,num ")-(" ,num "," ,num ")" ,war)) 1 (2 . 4) (3 . 5) 1 1 (6 'compilation-warning)) - ;; tasty / hspec and miscellaneous ghc extra info + ;; tasty / hspec (,(rx-to-string `(: bol (? (+ space) "error, called at") (+ space) (? "(") ,file ":" ,num ":" ,num (? "-" ,num ":"))) 1 2 (3 . 4) 2 1) diff --git a/test/compile/ghc-9.2.7-details.compile b/test/compile/ghc-9.2.7-details.compile new file mode 100644 index 0000000000..066a364bdf --- /dev/null +++ b/test/compile/ghc-9.2.7-details.compile @@ -0,0 +1,17 @@ +library/HsInspect/Index.hs:186:22: error: + • Couldn't match type ‘GHC.PackageId’ with ‘PackageId’ + Expected: Maybe PackageId + Actual: Maybe GHC.PackageId + NB: ‘PackageId’ is defined at library/HsInspect/Index.hs:310:1-53 + ‘GHC.PackageId’ + is defined in ‘GHC.Unit.Info’ in package ‘ghc-9.2.7’ + • In the first argument of ‘Exported’, namely ‘pid’ + In the expression: Exported pid (mkModuleName m) + In the expression: + let + unitid' = GHC.toUnitId . GHC.moduleUnit $ m + pid = if unitid == unitid' then Nothing else findPid unitid' + in Exported pid (mkModuleName m) + | +186 | in Exported pid (mkModuleName m) + | ^^^ diff --git a/test/compile/ghc-9.2.7-details.compile.faceup b/test/compile/ghc-9.2.7-details.compile.faceup new file mode 100644 index 0000000000..c166ce88e5 --- /dev/null +++ b/test/compile/ghc-9.2.7-details.compile.faceup @@ -0,0 +1,17 @@ +«U:«:compilation-error:library/HsInspect/Index.hs»»:«:compilation-line-number:186»:«:compilation-column-number:22»: «:compilation-error:error»: + • Couldn't match type ‘GHC.PackageId’ with ‘PackageId’ + Expected: Maybe PackageId + Actual: Maybe GHC.PackageId + NB: ‘PackageId’ is defined at «U:«:compilation-info:library/HsInspect/Index.hs»»:«:compilation-line-number:310»:«:compilation-column-number:1»-«:compilation-column-number:53» + ‘GHC.PackageId’ + is defined in ‘GHC.Unit.Info’ in package ‘ghc-9.2.7’ + • In the first argument of ‘Exported’, namely ‘pid’ + In the expression: Exported pid (mkModuleName m) + In the expression: + let + unitid' = GHC.toUnitId . GHC.moduleUnit $ m + pid = if unitid == unitid' then Nothing else findPid unitid' + in Exported pid (mkModuleName m) + | +186 | in Exported pid (mkModuleName m) + | ^^^ diff --git a/test/haskell-tng-compile-test.el b/test/haskell-tng-compile-test.el index ed1e7722d1..08f1ca20ac 100644 --- a/test/haskell-tng-compile-test.el +++ b/test/haskell-tng-compile-test.el @@ -53,6 +53,9 @@ (should (have-expected-errors (testdata "compile/ghc-8.4.4-warning.compile"))) (should (have-expected-errors (testdata "compile/ghc-8.4.4-warningspan.compile")))) +(ert-deftest haskell-tng-compile-details-file-tests () + (should (have-expected-errors (testdata "compile/ghc-9.2.7-details.compile")))) + (ert-deftest haskell-tng-compile-hspec-file-tests () (should (have-expected-errors (testdata "compile/hspec-failure.compile"))))