Odin
Odin copied to clipboard
Silent crash when calling procs from slice-of-procs within parapoly proc
If I try to call applier, then the compiler silently crashes.
The exact same process of iterating over a slice of procs, and calling each proc, outside of the parapoly applier proc works just fine.
So, something funky is happening specifically regarding the parapoly.
import "core:fmt";
import "core:slice"
//Compile fails if this is called
applier :: proc(s: $S/[]$U, fs: []proc(U) -> $V, allocator := context.allocator) -> []V {
new_len := len(s) * len(fs)
rs := make([]V, new_len)
i := 0
for i < new_len {
for f in fs {
for v in s {
rs[i] = f(v)
i += 1
}
}
}
return rs
}
import "core:strings"
main :: proc(){
make_honks :: proc (count:int) -> string {
return strings.repeat("honk!", count)
}
juggle_bananas :: proc (count:int) -> string {
return fmt.tprintf("%v bananas juggled!", count)
}
procs := []proc(int)->string{make_honks, juggle_bananas}
input_ints := []int{4,2,6}
// fmt.printf("APPLIER PARAPOLY: Expect 4,2,6 honks, bananas juggled %v \n", applier(input_ints, procs)) // If uncommented, there is a compile failure
//Below is the same logic as inside applier, but there is a compile failure if the generic is attempted
new_len := len(input_ints) * len(procs)
outside_of_generic := make([]string, new_len)
i := 0
for i < new_len {
for f in procs {
for v in input_ints {
outside_of_generic[i] = f(v)
i += 1
}
}
}
fmt.printf("OUTSIDE OF PARAPOLY: Expect 4,2,6 honks, bananas juggled %v \n", outside_of_generic)
};
Ran it through remedyBG and got this. No idea what to do with it - but this is where the exception happens

Does this still happen?
Yes, it still happens.