Skip to content

bug: array of function references fails at C codegen #1439

@SchoolyB

Description

@SchoolyB

Summary

Storing function references in an array (`[func]`) passes typechecking but fails at C compilation. The codegen emits `int64_t[]` for the element storage instead of function pointer types.

Reproduction

```ez
do add(a int, b int) -> int { return a + b }
do sub(a int, b int) -> int { return a - b }

do main() {
mut ops [func] = {()add, ()sub}
println(ops[0](10, 3))
println(ops[1](10, 3))
}
```

Expected: Prints `13` then `7`

Actual: C compilation error: `incompatible pointer to integer conversion`

Where to Fix

`ezc/src/codegen/codegen.c` — the array element type dispatch needs a case for function pointer types, emitting the correct C function pointer type instead of `int64_t`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodegenRelated to C code generationezcEZC compiler tool (EZ → C → native binary)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions