Recursing keyword's children in Lua creates stack overflow
Having progressed my keywording script, I've one task left which is to extend a function that creates a map of keyword name -> id so that it handles child keywords. I naively tried:
local function find_all_keywords()
local all_keywords = {}
local function find (keyword)
all_keywords[keyword:getName()]=keyword.localIdentifier
for _, child in ipairs (keyword:getChildren()) do find (keyword) end
end
for _, keyword in ipairs (catalog:getKeywords ()) do find (keyword) end
return all_keywords
end
However, when executing this, it creates a stack overflow which I don't understand. My keywords are only about 5 deep, and I think my logic would only attempt to find children of parents which should terminate at each leaf node?
?:0: stack overflow
