euclidianAce / ltreesitter

Standalone tree sitter bindings for the Lua language
MIT License
85 stars 4 forks source link

Many objects get garbage collected when they shouldn't #1

Closed euclidianAce closed 3 years ago

euclidianAce commented 3 years ago

Ideally this should be compatible for 5.1-5.4+JIT so no uservalues to hold a reference to the required objects.

Minimal example: iterating over the matches of a query done 'inline' to a for loop causes it to be garbage collected

for match in parser:query[[ ... ]]:match(node) do
   collectgarbage()
end

will segfault often, whereas

local q = parser:query[[ ... ]]
for match in q:match(node) do
   collectgarbage()
end

wont, due to the alive reference to q