ooc-lang / rock

:ocean: self-hosted ooc compiler that generates c99
http://ooc-lang.org/
MIT License
401 stars 40 forks source link

Rock doesn't always resolve type template instances, leading to backend crashes #964

Closed alexnask closed 8 years ago

alexnask commented 8 years ago

For example:

Foo: cover template <T> {
    fn: Func <T> (T)

    init: func@ (=fn)
}

foo: Foo<Int>

Here, Foo<Int> is never resolved (both with master and my class_template branch), init is never resolved, leading to =fn never being resolved and not getting a type, which the backend tries to write blindly.
The result, unsurprisingly, is a segfault.

(For some reason, the exact same code with class instead of cover and func instead of func@ has its instance resolved on my class_template branch).

It looks like we are relying on something wholeAgain-ing at the moment, which should not be the case.

alexnask commented 8 years ago

Here is a simpler case:

Foo: cover template <T> {
    val: T

    init: func@ (=val)
}

foo: Foo<Int>

Which leads to [Exception in BaseType]: Trying to write unresolved type T, which is the exact same bug.

alexnask commented 8 years ago

Of course, accessing val leads to Foo<Int> being resolved but this should be done automatically on instanciation (which may prove to be quite the challenge)