-
-
Notifications
You must be signed in to change notification settings - Fork 849
Open
Description
Context
Odin: dev-2025-11-nightly:e5153a9
OS: macOS Sequoia 15.7.1 (build 24G231, kernel 24.6.0)
CPU: Apple M3 Pro
RAM: 36864 MiB
Backend: LLVM 20.1.8
Expected Behavior
Using the #optional_ok directive should work as long as the last returned value is a boolean.
Current Behavior
The compiler emits the following error with procedures emitting more two return values:
Error: A procedure type with the #optional_ok tag requires 2 return values, got 3
foo :: proc(x: int) -> (a, b: int, ok: bool) #optional_ok {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Failure Information
In the Overview documentation, the #optional_ok directive is defined with:
Allows skipping the last return parameter, which needs to be a bool
This implies that number of return values should not matter, as long as last one is a boolean.
I am unable to find other documentation that defines the directive to apply when exactly two values are returned.
Steps to Reproduce
Attempt to compile a modified version of the #optional_ok directive's example on the Overview:
package example
import "core:fmt"
foo :: proc(x: int) -> (a, b: int, ok: bool) #optional_ok {
return x + 1, x + 2, true
}
main :: proc() {
ok: bool
x, y: int
for i in 0..<11 {
x, y, ok = foo(i)
fmt.printf("v: %v %v (%v)\n", x, y, ok)
}
}
If the #optional_ok directive is removed, the program compiles and runs.
Metadata
Metadata
Assignees
Labels
No labels