AttributeError: '_SnippetsFileParser' object has no attribute '_sm'
blueyed opened this issue · 2 comments
This just happened, when I have triggered Ultisnips:
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. See doc/UltiSnips-Quickstart.txt about how to contact the
maintainer for this UltiSnips fork and where you should file a bug report
Following is the full stack trace:
Traceback (most recent call last):
File "ultisnips/py-code/UltiSnips/__init__.py", line 26, in wrapper
return f(self, *args, **kwds)
File "ultisnips/py-code/UltiSnips/__init__.py", line 637, in expand_or_jump
rv = self._try_expand()
File "ultisnips/py-code/UltiSnips/__init__.py", line 979, in _try_expand
snippets = self._snips(before, False)
File "ultisnips/py-code/UltiSnips/__init__.py", line 895, in _snips
for snippet in ss.snippets():
File "ultisnips/py-code/UltiSnips/__init__.py", line 557, in snippets
self.parse(mtime)
File "ultisnips/py-code/UltiSnips/__init__.py", line 549, in parse
p.parse()
File "ultisnips/py-code/UltiSnips/__init__.py", line 253, in parse
p = _SnippetsFileParser(self._ft, filename, self._sm.snippet_error, None)
AttributeError: '_SnippetsFileParser' object has no attribute '_sm'
Your'e a dev, right? So you should know what is required for me to reproduce a bug: 1) yoru snippets 2) your config 3) your action in Vim.
The fastest way would be you pinging me on irc, then we both reproducing your setup on my server, us then fixing it
I just wanted to leave it here for later (quickly copy'n'pasted), and I did not remember what triggered it.
From looking at the code it appears as follows:
_sm
is only used in the code around there (inparse
).- the positional argument to _SnippetsFileParser is meant to be a error function, and is assigned as
self._error_fun
in init. - Since this is meant to be a recursion, it seems like
self._error_fun
should be used here instead.
The 2nd reference to self._sm
below should probably get replaced by UltiSnips_Manager
:
elif head == "clearsnippets":
self._sm.clear_snippets(tail.split(), self._ft)
To reproduce it you probably just need a snippet with "extends" (this issue) and "clearsnippets", second issue.
I am committing a fix (to my repo), please take a look at it and cherry-pick/merge it if it's OK.