fredreichbier / ooc-lua

lua binding for ooc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stack overflow when no constructor was found

fredreichbier opened this issue · comments

Using Type new(...) when there is no corresponding init makes Lua stack overflow. Probably shouldn't.

This happens with all static functions in superclasses. If howling doesn't know a certain member, it does function lookup by accessing __super__ of the instance. For static functions, there is no instance, and so __super__ does not exist, so howling tries to access __super__ to ask the superclass for it ... Yeah. I'll add an assert so it dies instead of stackoverflowing.

Note that 'final' static functions (such as 'new') shouldn't be callable from a subclass. For example:

Foo: class {
  init: func
}

Bar: class {
  init: func (a: Int)
}

Foo new() // builds a Foo
Bar new(42) // builds a Bar
Bar new() // compilation error - previously used to (erroneously) build a Foo instead.

Good point! I made #10.