Yonaba / Lua-Class-System

Lua Class System (LCS) is a small library which offers a clean, minimalistic but powerful API for (Pseudo) Object Oriented programming style using Lua.
http://yonaba.github.com/Lua-Class-System
64 stars 17 forks source link

Method inheritance problem #10

Closed ProGM closed 10 years ago

ProGM commented 10 years ago

I'm having an issue in this situation:

local A = LCS.class {} 
function A:someMethod()
    print("do something")
end
local B = A:extends{}
function B:callmethod2()
    self:method2()
end
function B:method2()
    print("I'm superclass 2")
end
local C = B:extends{}

function C:method2()
     self:super('method2')
end
local C_inst = C:new()
C:callmethod2() -- ERROR: LCS.lua:155: attempt to call local 'method' (a nil value)

I'm defining a class A, then a class B with a certain method "method2". Then I'm defining C, as child of B, and overwriting "method2". If I call a method of C defined in B that calls my method2, LCS crashes. Is it a bug?

Yonaba commented 10 years ago

Hi, @ProGM,

This should be fixed with this commit. I'll need to update the documentation and specs, and bump to 1.3.0. Thanks noticing me about this, though. And sorry it took so long, I have been very busy lately.

Regards, Roland.