stack overflow when no constructor was found
fredreichbier opened this issue · comments
Friedrich Weber commented
Using Type new(...)
when there is no corresponding init
makes Lua stack overflow. Probably shouldn't.
Friedrich Weber commented
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.
Amos Wenger (old) commented
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.
Friedrich Weber commented
Good point! I made #10.