Files
Odin/tests/issues/test_issue_disabled_proc_value.odin
T
bbodi d65a9ba9bc Keep disabled procedures whose value is taken
A procedure with `@(disabled=true)` adds no dependency where it is
used, so that the calls to it, which are removed, do not pull it in.
Taking its value, e.g. `rawptr(assert)` with `-disable-assert`, then
referenced a procedure that was never generated, and LLVM asserted
"missing procedure 'assert'".

Add the dependency for every use that is not the callee of a call.
2026-10-08 15:51:24 +02:00

27 lines
629 B
Odin

// Calls to a `@(disabled=true)` procedure are removed, but its value can still be taken.
// Built with `-disable-assert`, `rawptr(assert)` used to fail with "missing procedure 'assert'".
package test_issues
import "base:runtime"
import "core:testing"
@(disabled=true)
disabled_proc :: proc(n: ^int) { n^ += 1 }
global_assert := rawptr(assert)
@(test)
test_disabled_proc_value :: proc(t: ^testing.T) {
testing.expect(t, rawptr(assert) != nil)
testing.expect(t, rawptr(runtime.assert) == global_assert)
n := 0
disabled_proc(&n)
testing.expect_value(t, n, 0)
p := disabled_proc
p(&n)
testing.expect_value(t, n, 1)
}