From 774da8f75556722f684ba7b8c09b72e64d7d9561 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:10:44 +1000 Subject: [PATCH] fix(class): use rawset during instantiation If classes use a __newindex method it may lead to unexpected behaviour. --- imports/class/shared.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/class/shared.lua b/imports/class/shared.lua index 6336d68..bcbd258 100644 --- a/imports/class/shared.lua +++ b/imports/class/shared.lua @@ -63,17 +63,17 @@ function mixins.new(class, ...) if constructor then local parent = class - function obj:super(...) + rawset(obj, 'super', function(self, ...) parent = getmetatable(parent) constructor = getConstructor(parent) if constructor then return constructor(self, ...) end - end + end) constructor(obj, ...) end - obj.super = nil + rawset(obj, 'super', nil) if next(obj.private) then local private = table.clone(obj.private)