Operating System & Odin Version:
Odin: dev-2024-02-nightly:539cec74
OS: Windows 11 Professional (version: 23H2), build 22631.3085
CPU: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
RAM: 16301 MiB
Expected Behavior
Declaring a varargs parameter that also declares use of a polymorphic should work in the same as if the polymorphic type was already define before (see examples); or an error message explaining why this isn't possible.
Current Behavior
A declaration like this
proc(input: ..$T) -> T
causes the following error at compile time:
Ambiguous call to a polymorphic variadic procedure with no variadic input proc(..[]$T, string) -> []$T
Steps to Reproduce
Here is a minimal repro:
package bug
main :: proc() {
sum(1)
}
sum :: proc(input: ..$T) -> (sum: T) {
for i in input do sum += i
return
}
The problem only appears if the $T is declared by the varargs parameter. The following example compiles and works as expected:
package works
main :: proc() {
sum(int, 1, 2)
}
sum :: proc($T: typeid, input: ..T) -> (sum: T) {
for i in input do sum += i
return
}
Same if the first parameter is for example something like first: $T.
This was tested on both Windows and Mac and it fails in the same way.
Context
Expected Behavior
Declaring a varargs parameter that also declares use of a polymorphic should work in the same as if the polymorphic type was already define before (see examples); or an error message explaining why this isn't possible.
Current Behavior
A declaration like this
proc(input: ..$T) -> T
causes the following error at compile time:Ambiguous call to a polymorphic variadic procedure with no variadic input proc(..[]$T, string) -> []$T
Steps to Reproduce
Here is a minimal repro:
The problem only appears if the
$T
is declared by the varargs parameter. The following example compiles and works as expected:Same if the first parameter is for example something like
first: $T
.This was tested on both Windows and Mac and it fails in the same way.