luau
luau copied to clipboard
`collectgarbage` is "unknown global" in analysis and incorrectly documented
When using luau-analyze, it warns that collectgarbage
is an unknown global despite this not being the case. collectgarbage
should be added as a global in analysis, with it's parameter typed as taking "collect"
and "count"
I use the collectgarbage("collect")
method intensively in test cases for a library I'm working on (fewkz/cells/test.luau) to ensure there's no memory leaks, it's an invaluable method, but luau-analyze keeps complaining about it not existing.
In the Luau documentation, the collectgarbage
function is incorrectly documented as not taking "collect"
as an argument, despite this working perfectly fine, and indeed collecting garbage. The code collectgarbage("foo")
even results in the error "collectgarbage must be called with 'count' or 'collect'"
The documentation should be changed to reflect that "collect" is a valid argument to collectgarbage
on https://luau-lang.org/sandbox
This is messy and requires some sort of resolution :( It has to do with differences between Luau and Roblox library environment, and documentation / type checking being conservative. We'll need to figure out how to resolve this.