Commits

Bart van Strien committed ab146d0

Fix number indexes broken with a __getattr__ (because of __*__ getattr prevention)

  • Participants
  • Parent commits c2ce927

Comments (0)

Files changed (2)

 			for i, v in ipairs(b) do
 				if v[key] then return v[key] end
 			end
-			if key:match("^__.+__$") then return end
+			if tostring(key):match("^__.+__$") then return end
 			if self.__getattr__ then
 				return self:__getattr__(key)
 			end
 	Test()
 end)
 
+Test("Number indexes and __*__ getattr prevention", function()
+	class "Test"
+	{
+		__getattr__ = function(self, key)
+			if type(key) == "string" then
+				error("__getattr__ reached on __*__")
+			end
+			return true
+		end,
+	}
+
+	test = Test()
+	assert(test[1])
+	assert(not test["__init__"])
+end)
+
 Test("Deep inheritance", function()
 	class "A"
 	{