Ensure there is a nested table allocated for #set!

Fixes the following bug:
```
test/functional/helpers.lua:107: Error executing lua:
vim/treesitter/query.lua:256: attempt to index a nil value
```
This commit is contained in:
derekstride
2021-04-21 12:10:48 -02:30
parent fbe18d9ca4
commit 44d4526e18
2 changed files with 55 additions and 1 deletions

View File

@@ -253,7 +253,11 @@ local directive_handlers = {
["set!"] = function(_, _, _, pred, metadata)
if #pred == 4 then
-- (#set! @capture "key" "value")
metadata[pred[2]][pred[3]] = pred[4]
local capture = pred[2]
if not metadata[capture] then
metadata[capture] = {}
end
metadata[capture][pred[3]] = pred[4]
else
-- (#set! "key" "value")
metadata[pred[2]] = pred[3]