Fatal application exit when calling function of inherited class
ValetNoir opened this issue · comments
Hey ! I was trying to have a parent class contain an empty draw function, so I could overwrite it with an argument (else I couldn't, it would give me a weird error: 'de-indentation' expected, found 'indentation'
) in the child classes (not really useful when I think about it 🤔) and I got the "send this to the developper window".
Here is a repro case:
class Foo:
def foo() -> void
class FooFoo: Foo
// trying to overwrite the function
def foo(text: string):
print(text)
let a = Foo {}
a.foo()
// same with child class
// let a = FooFoo {}
// a.foo() // <- forget to pass an argument, calls the wrong version of the function
and the log: lobster.exe.exp.log
Thanks for taking a look 😁 !
I will have a look at it, thanks!
Btw, in Lobster you don't even need to declare "empty" functions in the parent class, as long as you don't instantiate the parent. You could even mark the parent abstract
to enforce that.
Fixed in b53ef6a
def foo() -> void
indeed declares a function type. The error was that it allowed a function type and a regular function to share the same name, and then when calling it, it didn't notice it was calling a type because there was also a regular function version. All of that is now disallowed :)
Thanks a lot for the advices and for the fix !