ooc-lang / rock

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

Unused cover templates make rock segfault #959

Closed alexnask closed 8 years ago

alexnask commented 8 years ago

I was playing with cover templates a bit, trying to write an ArrayList implementation, when I noticed this:

Foo: cover template <T> {
    init: func@
}

// Uncommenting this stops rock from crashing
// foo := Foo<Int> new()
alexnask commented 8 years ago

Here is my completed (minus iterators, will do them soon), untested (add~withIndex is probably wrong) cover template ArrayList, if anyone is curious by the way:

https://gist.github.com/shamanas/f50f52fa77f824b34a68

I think the way I did it with a SafeArray + SafeArrayRange would actually also allow specialization without memcpy/memmove (by using range assignment with cover templates)

EDIT: This code is way too big, moved to a gist