Commits

Bart van Strien committed d416ad0

Fix a bug with __getattr__ being called for __*__, especially when instantiating

Comments (0)

Files changed (2)

 			for i, v in ipairs(b) do
 				if v[key] then return v[key] end
 			end
-			if key == "__getattr__" then return end
-			if key == "__setattr__" then return end
+			if key:match("^__.+__$") then return end
 			if self.__getattr__ then
 				return self:__getattr__(key)
 			end
 	assert(TestClass == nil)
 	assert(test)
 end)
+
+Test("__getattr__ not getting other __*__", function()
+	class "Test" {
+		__getattr__ = function()
+			error("__getattr__ reached")
+		end,
+	}
+	-- __getattr__ used to get called on __*__
+	-- in init in the past, make sure it's fixed
+	Test()
+end)