From 3b6b31266d3d3948dd8d32f6602ff7c37fbffa8c Mon Sep 17 00:00:00 2001 From: caijietao Date: Mon, 24 Apr 2017 15:23:12 +0800 Subject: [PATCH] error report on sharedata newindex --- lualib/sharedata/corelib.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lualib/sharedata/corelib.lua b/lualib/sharedata/corelib.lua index bd42cf1b..05a14b2f 100644 --- a/lualib/sharedata/corelib.lua +++ b/lualib/sharedata/corelib.lua @@ -71,6 +71,10 @@ local function getcobj(self) return obj end +function meta:__newindex(key, value) + error ("Error newindex, the key [" .. genkey(self) .. "]") +end + function meta:__index(key) local obj = getcobj(self) local v = index(obj, key) @@ -78,7 +82,7 @@ function meta:__index(key) local children = self.__cache if children == nil then children = {} - self.__cache = children + rawset(self, "__cache", children) end local r = children[key] if r then