Description
When function references are appended to a [func] array via arrays.append(), codegen emits sizeof(__auto_type) to determine element size. __auto_type is not valid inside sizeof() in C.
Repro
import @arrays
do is_pos(n int) -> bool { return n > 0 }
do is_neg(n int) -> bool { return n < 0 }
do main() {
mut preds [func(int) -> bool] = {}
arrays.append(preds, ()is_pos)
arrays.append(preds, ()is_neg)
println(preds[0](5))
}
Expected: Compiles and prints true.
Actual: C compilation error — sizeof(__auto_type) is not valid.
Root cause
The element type switch in emit_arrays_call() for append and insert_at didn't handle TK_FUNCTION. Function references fell through to the __auto_type default. Since func refs are stored as void* in arrays, the correct C type is void *.
Description
When function references are appended to a
[func]array viaarrays.append(), codegen emitssizeof(__auto_type)to determine element size.__auto_typeis not valid insidesizeof()in C.Repro
Expected: Compiles and prints
true.Actual: C compilation error —
sizeof(__auto_type)is not valid.Root cause
The element type switch in
emit_arrays_call()forappendandinsert_atdidn't handleTK_FUNCTION. Function references fell through to the__auto_typedefault. Since func refs are stored asvoid*in arrays, the correct C type isvoid *.