-
Notifications
You must be signed in to change notification settings - Fork 378
Open
Labels
Description
Issue Description
A function that accepts a functype or IFunc containing vector<float, N> doesn't always make use of the vector<float, 1> to float implicit cast. The behavior is slightly different depending on whether functype or IFunc is used.
Reproducer Code
#language slang 2026
func foo1 (f: functype() -> vector<float, 1>) {}
func foo2<let N:int>(f: functype() -> vector<float, N>) {}
func foo3<let N:int>(f: IFunc<vector<float, N>>) {}
func main() {
// valid
foo1(() => 5.0);
foo2<1>(() => 5.0);
foo3(() => vector<float, 1>(5.0));
// error
foo2(() => 5.0);
foo2(() => vector<float, 1>(5.0));
foo3(() => 5.0);
foo3<1>(() => 5.0);
}slangc test.slang
Expected Behavior
Test code should compile successfully in each case; the float return type should match vector<float, 1>, which in turn deduces N to be 1.
Actual Behavior
test.slang(14): error 39999: could not specialize generic for arguments of type (main._slang_Lambda_main_4)
foo2(() => 5.0);
^
test.slang(4): note: see declaration of func foo2<int N> -> void
func foo2<let N:int>(f: functype() -> vector<float, N>) {}
^~~~
test.slang(15): error 39999: could not specialize generic for arguments of type (main._slang_Lambda_main_5)
foo2(() => vector<float, 1>(5.0));
^
test.slang(4): note: see declaration of func foo2<int N> -> void
func foo2<let N:int>(f: functype() -> vector<float, N>) {}
^~~~
test.slang(16): error 30019: expected an expression of type 'IFunc<vector<float,1>, >', got 'main._slang_Lambda_main_6'
foo3(() => 5.0);
^~
test.slang(17): error 30019: expected an expression of type 'IFunc<vector<float,1>, >', got 'main._slang_Lambda_main_7'
foo3<1>(() => 5.0);
^~
Environment
- Slang 2025.22
- openSUSE Tumbleweed (x86-64)
Additional context
The desired behavior is useful when creating generic second-order functions that work with both vectors and scalars.