SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.55k stars 691 forks source link

RecursionError: maximum recursion depth exceeded in comparison #1532

Open Hubro opened 1 year ago

Hubro commented 1 year ago

Sorry in advance, but I am unable to reproduce this issue, it seems to happen at random maybe a couple of times per day. I have tried to find a way to reproduce it the last couple of weeks, but I can't. It's annoying me so much I need to post it, in case you have an easy solution.

Sometimes my editor freezes for a long time before I get this error (like minutes), other times I get it instantly after filling out a snippet.

The last couple of times the error happened, it was while filling in a Rust LSP-provided snippet inside of a custom Ultisnips snippet, i.e.:

assert_eq!(
    unique_paths(3, 7),
    28,
);

assert_eq! above is a custom Ultisnips snippet, where I expanded the unique_paths snippet from the LSP in the first position. I got the error when pressing <Esc> to leave the snippet context.

The error is:

An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://github.com/SirVer/ultisnips/issues/new
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs

Following is the full stack trace:
Traceback (most recent call last):
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py", line 47, in wrapper
    return func(self, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 415, in _cursor_moved
    self._active_snippets[0].replay_user_edits(es, self._ctab)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/snippet_instance.py", line 70, in replay_user_edits
    self._do_edit(cmd, ctab)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit
    self._do_edit(child)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit
    self._do_edit(child)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit
    self._do_edit(child)
  [Previous line repeated 958 more times]
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 246, in _do_edit
    child._do_edit(cmd, ctab)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 290, in _do_edit
    self._child_has_moved(idx, pivot, delta)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 304, in _child_has_moved
    child._move(pivot, diff)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 296, in _move
    child._move(pivot, diff)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 293, in _move
    TextObject._move(self, pivot, diff)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 67, in _move
    self._start.move(pivot, diff)
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/position.py", line 23, in move
    if self < pivot:
       ^^^^^^^^^^^^
  File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/position.py", line 62, in __lt__
    return (self.line, self.col) < (other.line, other.col)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded in comparison

Has anybody else had this same issue? Is there something obvious causing it?


SirVer commented 1 year ago

Can you post the snippet definition?Am 08.07.2023 um 22:03 schrieb Tomas Sandven @.***>: Sorry in advance, but I am unable to reproduce this issue, it seems to happen at random maybe a couple of times per day. I have tried to find a way to reproduce it the last couple of weeks, but I can't. It's annoying me so much I need to post it, in case you have an easy solution. Sometimes my editor freezes for a long time before I get this error (like minutes), other times I get it instantly after filling out a snippet. The last couple of times the error happened, it was while filling in a Rust LSP-provided snippet inside of a custom Ultisnips snippet, i.e.: assert_eq!( unique_paths(3, 7), 28, ); assert_eq! above is a custom Ultisnips snippet, where I expanded the unique_paths snippet from the LSP in the first position. I got the error when pressing to leave the snippet context. The error is: An error occured. This is either a bug in UltiSnips or a bug in a snippet definition. If you think this is a bug, please report it to https://github.com/SirVer/ultisnips/issues/new Please read and follow: https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs

Following is the full stack trace: Traceback (most recent call last): File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py", line 47, in wrapper return func(self, *args, **kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 415, in _cursor_moved self._active_snippets[0].replay_user_edits(es, self._ctab) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/snippet_instance.py", line 70, in replay_user_edits self._do_edit(cmd, ctab) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit self._do_edit(child) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit self._do_edit(child) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 274, in _do_edit self._do_edit(child) [Previous line repeated 958 more times] File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 246, in _do_edit child._do_edit(cmd, ctab) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 290, in _do_edit self._child_has_moved(idx, pivot, delta) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 304, in _child_has_moved child._move(pivot, diff) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 296, in _move child._move(pivot, diff) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 293, in _move TextObject._move(self, pivot, diff) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/text_objects/base.py", line 67, in _move self._start.move(pivot, diff) File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/position.py", line 23, in move if self < pivot: ^^^^^^^^^^^^ File "/home/tomas/.local/share/nvim/lazy/ultisnips/pythonx/UltiSnips/position.py", line 62, in lt return (self.line, self.col) < (other.line, other.col) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RecursionError: maximum recursion depth exceeded in comparison

Has anybody else had this same issue? Is there something obvious causing it?

Operating System: Arch Linux Vim Version: NVIM v0.9.1 UltiSnips Version: 24bca5c Python inside Vim: 3.11.3 Docker repo/vimrc: 😞

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

Hubro commented 1 year ago

@SirVer Of course, though it's so simple I assumed it wasn't relevant:

snippet assert_eq "An assertion" b
assert_eq!(
    ${1:A},
    ${0:B},
);
endsnippet
SirVer commented 1 year ago

Indeed, that snippet should not trigger such behaviour easily. So much more likely that there is interplay between UltiSnips and a different plugin.

Please provide a fully reproducible example, ideally using the approach explained in https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs or if not possible with a minimal vimrc and snippets files and an exact sequence of key strokes that trigger the bug.

Hubro commented 1 year ago

@SirVer I wish I could, but as I said in the original post, I'm unable to replicate it consistently, it seems to happen at random. It seems to be related to the interweaving of UltiSnips snippets and LSP snippets. It hasn't happened for a few days now (since I was working on a Rust project), so it might even be specific to the rust-analyzer LSP.

From now on, I'll make note of what I'm doing when this crash happens, and hopefully a pattern will emerge.