-
Notifications
You must be signed in to change notification settings - Fork 427
Description
Issue Description
Explicitly specializing a constrained generic function with an interface type — genericFunc<IFoo>(obj, 3.0) — crashes the compiler with error 99999: Unexpected context type for parameter info retrieval.
This is a different crash from #10263 (which uses implicit inference). When the same function is called with implicit inference (genericFunc(obj, 3.0)), the compiler correctly emits error 33180. The explicit specialization path hits a separate unhandled code path.
Reproducer Code
interface IFoo
{
float calc(float x);
}
struct A : IFoo { float calc(float x) { return x * 2.0; } }
struct B : IFoo { float calc(float x) { return x + 10.0; } }
float genericFunc<T : IFoo>(T obj, float x)
{
return obj.calc(x);
}
IFoo makeObj(int id)
{
if (id == 0) return A();
else return B();
}
RWStructuredBuffer<float> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(int id : SV_DispatchThreadID)
{
IFoo obj = makeObj(id);
float result = genericFunc<IFoo>(obj, 3.0); // CRASH
outputBuffer[0] = result;
}Command line:
slangc repro.slang -target hlsl -stage compute -entry computeMainExpected Behavior
The compiler emits error 33180 (consistent with the implicit inference case), since genericFunc(obj, 3.0) already produces that diagnostic.
Actual Behavior
(0): error 99999: Slang compilation aborted due to an exception of N5Slang13InternalErrorE: unexpected: Unexpected context type for parameter info retrieval
The crash occurs on all targets (spirv, hlsl, glsl).
Note: Changing to implicit inference — genericFunc(obj, 3.0) instead of genericFunc<IFoo>(obj, 3.0) — correctly produces:
error 33180: specializing '...' with an existential type is not allowed. All generic arguments must be statically resolvable at compile time.
Environment
- Slang Version: commit 6ffecd3 (master, 2026-02-26)
- OS: Linux 6.14.0-37-generic x86_64 (Ubuntu 24.04)
Additional Context
Found during issue #10290 testing. Related test file: tests/language-feature/dynamic-dispatch/diagnose-explicit-specialize-with-interface.slang.
This could be filed as a standalone issue or added as a note on #10263 since both involve interface types flowing into generic parameters.