fix(class): fixed private access in method calls (#553)

Co-authored-by: Linden <65407488+thelindat@users.noreply.github.com>
This commit is contained in:
deFuzz
2024-04-28 04:08:15 +02:00
committed by GitHub
parent 113f5227e5
commit 75f4ecbbea

View File

@@ -85,14 +85,14 @@ function mixins.new(class, ...)
__index = function(self, index) __index = function(self, index)
local di = getinfo(2, 'n') local di = getinfo(2, 'n')
if di.namewhat == 'local' then return end if di.namewhat ~= 'method' and di.namewhat ~= '' then return end
return private[index] return private[index]
end, end,
__newindex = function(self, index, value) __newindex = function(self, index, value)
local di = getinfo(2, 'n') local di = getinfo(2, 'n')
if di.namewhat ~= 'method' then if di.namewhat ~= 'method' and di.namewhat ~= '' then
error(("cannot set value of private field '%s'"):format(index), 2) error(("cannot set value of private field '%s'"):format(index), 2)
end end