From 6b4bc410d622253e48a7901081af9b1cb6747047 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Wed, 8 Nov 2017 11:19:31 +0000 Subject: [PATCH 1/2] Fix return of super.static if val false (fix #50) --- middleclass.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/middleclass.lua b/middleclass.lua index 0d9a834..5f0aeef 100644 --- a/middleclass.lua +++ b/middleclass.lua @@ -79,7 +79,15 @@ local function _createClass(name, super) subclasses = setmetatable({}, {__mode='k'}) } if super then - setmetatable(aClass.static, { __index = function(_,k) return rawget(dict,k) or super.static[k] end }) + setmetatable(aClass.static, { + __index = function(_,k) + local result = rawget(dict,k) + if result == nil { + return super.static[k] + } + return result + end + }) else setmetatable(aClass.static, { __index = function(_,k) return rawget(dict,k) end }) end From c13b4a4f6a16e582b0d4adfe5e3ecfd822fab766 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Wed, 8 Nov 2017 13:45:31 +0000 Subject: [PATCH 2/2] Fix use of C-syntax --- middleclass.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleclass.lua b/middleclass.lua index 5f0aeef..b118f17 100644 --- a/middleclass.lua +++ b/middleclass.lua @@ -82,9 +82,9 @@ local function _createClass(name, super) setmetatable(aClass.static, { __index = function(_,k) local result = rawget(dict,k) - if result == nil { + if result == nil then return super.static[k] - } + end return result end })