Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three levels of subclassing causes stack overflow in constructor #12

Open
drauschenbach opened this issue Dec 16, 2018 · 0 comments
Open

Comments

@drauschenbach
Copy link

Busted-based unit test:

describe('microlight.class', function()
  it('Three levels of subclassing works', function()

    local microlight = require 'ml'
    local A = microlight.class()
    function A:_init()
      self.me='a'
    end

    local B = microlight.class(A)
    function B:_init()
      self:super()
      self.me='b'
    end

    local C = microlight.class(B)
    function C:_init()
      self:super()
      self.me='c'
    end
    
    local a = A()
    local b = B()
    local c = C()
    
    assert.equals('a', a.me)
    assert.equals('b', b.me)
    assert.equals('c', c.me)
  end)
  
end)

Output:

0 successes / 0 failures / 1 error / 0 pending : 0.211254 seconds

Error -> spec/stuart/class_spec.lua @ 117
class Three levels of subclassing works in microlight
spec/stuart/class_spec.lua:125: stack overflow

stack traceback:
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        spec/stuart/class_spec.lua:125: in function 'super'
        ...
        /usr/local/share/lua/5.2/busted/core.lua:312: in function 'execute'
        /usr/local/share/lua/5.2/busted/block.lua:155: in function 'execute'
        /usr/local/share/lua/5.2/busted/init.lua:7: in function 'executor'
        /usr/local/share/lua/5.2/busted/core.lua:312: in function </usr/local/share/lua/5.2/busted/core.lua:312>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant