Description
When I am in haskell-mode, and type M-. to find the source of the definition under point, and the definition under point is in a different file, I get the following error message in the Messages buffer:
error: "Marker points into wrong buffer", #<marker at 15335 in Snaplet.hs>
(defun haskell-mode-jump-to-def-or-tag (&optional _next-p)
;; FIXME NEXT-P arg is not used
"Jump to the definition.
Jump to definition of identifier at point by consulting GHCi, or
tag table as fallback.
Remember: If GHCi is busy doing something, this will delay, but
it will always be accurate, in contrast to tags, which always
work but are not always accurate.
If the definition or tag is found, the location from which you jumped
will be pushed onto `xref--marker-ring', so you can return to that
position with `xref-pop-marker-stack'."
(interactive "P")
(let ((initial-loc (point-marker))
(loc (haskell-mode-find-def (haskell-ident-at-point))))
(if loc
(haskell-mode-handle-generic-loc loc)
(call-interactively 'haskell-mode-tag-find))
(unless (equal initial-loc (point-marker))
(save-excursion
(goto-char initial-loc)
(xref-push-marker-stack)))))
This behaviour does NOT occur if haskell-mode-find-def fails and haskell-mode-tag-find is called and succeeds. I instrumented haskell-mode-jump-to-def-or-tag and found that the error happens at the (goto-char initial-loc) line in the code, hence the (xref-push-marker-stack) line isn't executed. However if haskell-mode-tag-find succeeds, the the previous location is indeed pushed (inside of haskell-mode-tag-find somewhere) so M-* (pop-tag-mark) works correctly. I hope this is helpful.
Best wishes,
Henry Laxen