Skip to content

Silent nil on parapoly procedure with parapoly struct #7316

Description

@greenya

Context

    Odin:    dev-2026-08-nightly:902106f
    OS:      Ubuntu Stonking Stingray (development branch), Linux 7.0.0-15-generic
    CPU:     Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    RAM:     31950 MiB
    Backend: LLVM 20.1.8

Expected Behavior

The initialized value should contain all fields. Maybe fail to compile with error, but not silent nils.

Current Behavior

The initialized value is incomplete, some procedure pointers are left uninitialized.

Failure Information (for bugs)

Please consider the following code:

package main

import "core:fmt"

Foo :: struct ($N: int) {
    data    : [N] u8,
    number  : int,
    update  : proc (f: ^Foo(N), delta: int),
    print   : proc (f: Foo(N)),
}

foo_init :: proc (f: ^Foo($N), number: int) {
    f^ = {
        number  = 333,
        update  = foo_update,
        print   = foo_print,
    }
}

foo_update :: proc (f: ^Foo($N), delta: int) {
    f.number += delta
}

foo_print :: proc (f: Foo($N)) {
    fmt.println(#procedure, f.number)
}

main :: proc () {
    f: Foo(10)
    foo_init(&f, 555)

    fmt.println(f)
}

The output:

Foo($N=10){data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], number = 333, update = nil, print = nil}

Notice uninitialized pointers update and print -- unexpected. If we change single line number = 333, to number = number, in foo_init() -- so we're actually using provided argument; the output becomes expected:

Foo($N=10){data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], number = 555, update = proc(^Foo($N=10), int) @ 0x625CBF518750, print = proc(Foo($N=10)) @ 0x625CBF518780}

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions