howmanysmall / Janitor

Janitor library.
https://howmanysmall.github.io/Janitor/
MIT License
107 stars 17 forks source link

Fix Cleanup #30

Closed daimond113 closed 1 year ago

daimond113 commented 1 year ago

Fixes an issue within Cleanup where the Janitor wouldn't get marked as currently cleaning.

howmanysmall commented 1 year ago

The current behavior is intentional. You can check this with the following code:

local Test = {}
Test.ThisSaysTrue = true
Test.__index = Test

function Test.new()
    return setmetatable({
        ThisSaysTrue = false;
    }, Test)
end

function Test:Delete()
    self.ThisSaysTrue = nil
end

function Test:Return()
    self.ThisSaysTrue = false
end

local Class = Test.new()
print(Class.ThisSaysTrue)
Class:Delete()
print(Class.ThisSaysTrue)
Class:Return()
print(Class.ThisSaysTrue)

As you can see, it prints true when the value is nil because of the fact that the static reference with the same name exists.

image

daimond113 commented 1 year ago

Oh, I see. In that case I'm closing this pull request.