GNU bug report logs -
#77077
Markers in treesit_check_node
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Mon, 17 Mar 2025 18:01:02 UTC
Severity: normal
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> On Mar 17, 2025, at 10:52 AM, Juri Linkov <juri <at> linkov.net> wrote:
>
> In mhtml-ts-mode activate the region, type 'C-c C-t'
> and an element name like div, type RET RET, then:
>
> Debugger entered--Lisp error: (wrong-type-argument integerp #<marker (moves after insertion) at 10 in test.html>)
> treesit-query-capture(#<treesit-parser for html> #<treesit-compiled-query> 7 #<marker (moves after insertion) at 10 in test.html>)
> treesit-query-range(#<treesit-parser for html> #<treesit-compiled-query> 7 #<marker (moves after insertion) at 10 in test.html> nil nil)
> treesit--update-ranges-non-local(#<treesit-parser for html> #<treesit-compiled-query> javascript 32 1 7 #<marker (moves after insertion) at 10 in test.html> nil nil)
> treesit--update-range-1(7 #<marker (moves after insertion) at 10 in test.html> #<treesit-parser for html> ...)
> treesit-update-ranges(7 #<marker (moves after insertion) at 10 in test.html>)
> treesit-indent-region(7 #<marker (moves after insertion) at 10 in test.html>)
> indent-region(7 #<marker (moves after insertion) at 10 in test.html> nil)
> skeleton-internal-1(n t nil)
> skeleton-insert(... -1 nil)
> skeleton-proxy-new(... nil nil)
> sgml-tag(nil nil)
> funcall-interactively(sgml-tag nil nil)
> command-execute(sgml-tag)
>
> Here's the patch to fix this and it seems no more changes necessary
> since it fails only on checking, but on using it converts markers
> to numbers automatically.
>
> diff --git a/src/treesit.c b/src/treesit.c
> index b0979397d35..7df9bb4d0d3 100644
> --- a/src/treesit.c
> +++ b/src/treesit.c
> @@ -2190,6 +2190,9 @@ treesit_check_node (Lisp_Object obj)
> static void
> treesit_check_position (Lisp_Object obj, struct buffer *buf)
> {
> + if (MARKERP (obj))
> + obj = make_fixnum (marker_position (obj));
> +
> treesit_check_positive_integer (obj);
> ptrdiff_t pos = XFIXNUM (obj);
> if (pos < BUF_BEGV (buf) || pos > BUF_ZV (buf))
We call XFIXNUM (obj) after treesit_check_position in a lot of places. Your patch didn’t cause any crash? Anyway, I think we should keep treesit_check_position as-is. And change treesit-indent-region to convert markers to integers. Integer and marker might be interchangeable in Lisp, but I don’t think it’s a good idea to mingle them in C.
Yuan
This bug report was last modified 59 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.