Using map on ArrayList and then join gives segmentation fault

Skip to first unread message

Jul 30, 2015, 5:02:37 AM7/30/15
to ooc-lang

This is the code:
import structs/[ArrayList, List]

a := [1, 2, 3] as ArrayList<Int>
b := a map(func (value: Int) -> String { value toString()})
b join(", ") println()

When I run the above code with rock I get this:
(SIGSEGV) segmentation fault
[lang/Backtrace] Falling back on execinfo.. (build extension if you want fancy backtraces)
./GenericFuncInClassTest(lang_Backtrace__BacktraceHandler_backtrace_impl+0xf0) [0x44275e]
./GenericFuncInClassTest(lang_Backtrace__BacktraceHandler_backtrace+0x20) [0x443398]
./GenericFuncInClassTest(lang_Exception__Exception_getCurrentBacktrace+0x22) [0x42fa2b]
./GenericFuncInClassTest(lang_Exception___signalHandler+0x1a7) [0x43098b]
/lib/x86_64-linux-gnu/ [0x7f3b701a8d40]
./GenericFuncInClassTest(structs_List__List_itemsSizeInBytes_impl+0x72) [0x43a056]
./GenericFuncInClassTest(structs_List__List_itemsSizeInBytes+0x23) [0x43a97c]
./GenericFuncInClassTest(structs_List__List_join_string_impl+0x20) [0x43a11f]
./GenericFuncInClassTest(structs_List__List_join_string+0x2e) [0x43a9d1]
./GenericFuncInClassTest(GenericFuncInClassTest_load+0x1b9) [0x42b596]
./GenericFuncInClassTest(main+0x1e) [0x42b5d5]
/lib/x86_64-linux-gnu/ [0x7f3b70193ec5]
./GenericFuncInClassTest() [0x42b319]

Am I doing anything wrong or is this an issue with rock?


Amos Wenger

Jul 30, 2015, 5:54:17 AM7/30/15
to, ooc-lang
Your code should definitely work, but (*sigh*) rock probably generates invalid code without even erroring.

This equivalent code works:

import structs/ArrayList
([1, 2, 3] as ArrayList<Int>) map(|x| x toString()) join(", ") println()

(The important difference is in the call to map).

- Amos

You received this message because you are subscribed to the Google Groups "ooc-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Jul 30, 2015, 7:43:01 AM7/30/15
to ooc-lang,

Thank you it works now


Jul 30, 2015, 8:28:22 AM7/30/15
to ooc-lang,
On Thursday, July 30, 2015 at 11:54:17 AM UTC+2, fasterthanlime wrote:

I ran into a new problem when trying to implement fold.

This is the fold code:
fold: func <T,S> (function: Func(T, S) -> S, initial: S) -> S {
for(i in 0..this count)
initial = function(this[i], initial)

This is how I'm trying to use it:
import structs/[ArrayList, List]

a := [1, 2, 3] as ArrayList<Int>

b := a fold(|x, y| x toString() + y, "START")

And this is the error:
rock/./GenericFuncInClassTest.ooc:5:8 error Not enough info to resolve return type S of function call

b := a fold(|x, y| x toString() + y toString(), "START")

Is there a way to write the code to make it understand the return type?


Amos Wenger

Jul 30, 2015, 10:02:07 AM7/30/15
to, ooc-lang
I'm afraid not. It was probably broken in rock 0.9.10, when it became stricter on generics..

We're reaching the limits of what rock can do with generics due to its design. You could report an issue to, see if shamanas or someone else is willing to fix it, but I'm now focusing my efforts on cork — you can see the discussion here:

In the meantime, I'd suggest settling for more imperative code :(

- Amos

Jul 30, 2015, 10:58:16 AM7/30/15
to ooc-lang
Thank you for fast answers :)
I'ts nice to know the reson to the problem even if it dosen't solve it.


Reply all
Reply to author
0 new messages