stride3d/stride · error · InvalidOperationException

Intrinsic : Can't resolve parameter of type

Error message

Intrinsic {name}: Can't resolve parameter {index} of type {parameterType}

What it means

Thrown by IntrinsicTemplateExpander.TryGetOrGenerateIntrinsicsDefinition when expanding an SDSL intrinsic template: a parameter (or return) type cannot be resolved because its type slot is still unfilled and its match() reference either points back to itself or is otherwise unusable. The expander needs every parameter type resolved to a concrete base type before emitting the intrinsic, and it refuses to guess.

Solutions

  1. Fix the intrinsic declaration so match() arguments point to a different parameter index (never back to the parameter itself)
  2. Give the parameter an explicit concrete type instead of relying on match()
  3. Verify intrinsicDefinition.Parameters and Return in the .sdsl file for missing or self-referencing match() specifiers

Example fix

// before
float mul(intrin(match(0), match(0)) a);
// after
float mul(intrin(match(0)) a);
Defensive patterns

Strategy: validation

Validate before calling

// Before registering the intrinsic, check each parameter/return type is resolvable
foreach (var p in intrinsicDefinition.Parameters)
    if (p.Type.Match != null && p.Type.Match.Value.BaseType == ownIndex)
        throw new InvalidOperationException($"Intrinsic {name}: parameter matches itself");

Type guard

bool IsResolvable(ParsedType t) => t.BaseType != null && (t.Match == null || t.Match.Value.BaseType != ownIndex);

Prevention

When it happens

Trigger: Declaring an intrinsic whose parameter type uses match() that resolves back to the same parameter index, or leaving a parameter type without any way to infer it from thisType or a matched parameter.

Common situations: Hand-written or third-party .sdsl intrinsic files with a typo in match() arguments; intrinsic signatures copied from HLSL where the equivalent overload relied on implicit type deduction that SDSL cannot perform.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/897f4b475b583cef. Report an issue: GitHub.

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs:218

                SymbolType[] parameterTypes = new SymbolType[intrinsicDefinition.Parameters.Length + 1];
                foreach (var baseTypePermutationList in baseTypePermutations)
                {
                    Array.Clear(parameterTypeHelper);
                    // Use base type permutations to fill initial types
                    foreach (var baseTypePermutation in baseTypePermutationList)
                        parameterTypeHelper[baseTypePermutation.Generator.SourceArgument].BaseType = baseTypePermutation.Type;

                    // Set other parameters (which might use initial types)
                    // Only Match type should be left
                    for (var index = 0; index < intrinsicDefinition.Parameters.Length + 1; index++)
                    {
                        var parameterType = index > 0 ? intrinsicDefinition.Parameters[index - 1].Type : intrinsicDefinition.Return;
                        // Make sure this parameter is not set yet by something else
                        if (parameterTypeHelper[index].BaseType == null)
                        {
                            // Note: we also check match index doesn't point back to us
                            if (parameterType.Match == null || parameterType.Match.Value.BaseType == index)
                                throw new InvalidOperationException($"Intrinsic {name}: Can't resolve parameter {index} of type {parameterType}");

                            var matchBaseTypeIndex = parameterType.Match.Value.BaseType;
                            if (matchBaseTypeIndex == -1)
                            {
                                // Match thisType's base type
                                parameterTypeHelper[index].BaseType = thisType switch
                                {
                                    TextureType t => t.ReturnType.GetElementType(),
                                    BufferType b => b.BaseType.GetElementType(),
                                    AppendStructuredBufferType b => b.BaseType,
                                    ConsumeStructuredBufferType b => b.BaseType,
                                    StructuredBufferType b => b.BaseType,
                                    null => throw new ArgumentNullException(nameof(thisType)),
                                    _ => throw new InvalidOperationException($"Can't resolve thisType base type for {thisType}"),
                                };
                            }
                            else if (matchBaseTypeIndex == -3)
                            {

View on GitHub (pinned to 96fad776d2)