{"record":{"id":"897f4b475b583cef","repo":"stride3d/stride","slug":"intrinsic-name-can-t-resolve-parameter-index-of-type","errorCode":null,"errorMessage":"Intrinsic {name}: Can't resolve parameter {index} of type {parameterType}","messagePattern":"Intrinsic (.+?): Can't resolve parameter (.+?) of type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs","lineNumber":218,"sourceCode":"                SymbolType[] parameterTypes = new SymbolType[intrinsicDefinition.Parameters.Length + 1];\n                foreach (var baseTypePermutationList in baseTypePermutations)\n                {\n                    Array.Clear(parameterTypeHelper);\n                    // Use base type permutations to fill initial types\n                    foreach (var baseTypePermutation in baseTypePermutationList)\n                        parameterTypeHelper[baseTypePermutation.Generator.SourceArgument].BaseType = baseTypePermutation.Type;\n\n                    // Set other parameters (which might use initial types)\n                    // Only Match type should be left\n                    for (var index = 0; index < intrinsicDefinition.Parameters.Length + 1; index++)\n                    {\n                        var parameterType = index > 0 ? intrinsicDefinition.Parameters[index - 1].Type : intrinsicDefinition.Return;\n                        // Make sure this parameter is not set yet by something else\n                        if (parameterTypeHelper[index].BaseType == null)\n                        {\n                            // Note: we also check match index doesn't point back to us\n                            if (parameterType.Match == null || parameterType.Match.Value.BaseType == index)\n                                throw new InvalidOperationException($\"Intrinsic {name}: Can't resolve parameter {index} of type {parameterType}\");\n\n                            var matchBaseTypeIndex = parameterType.Match.Value.BaseType;\n                            if (matchBaseTypeIndex == -1)\n                            {\n                                // Match thisType's base type\n                                parameterTypeHelper[index].BaseType = thisType switch\n                                {\n                                    TextureType t => t.ReturnType.GetElementType(),\n                                    BufferType b => b.BaseType.GetElementType(),\n                                    AppendStructuredBufferType b => b.BaseType,\n                                    ConsumeStructuredBufferType b => b.BaseType,\n                                    StructuredBufferType b => b.BaseType,\n                                    null => throw new ArgumentNullException(nameof(thisType)),\n                                    _ => throw new InvalidOperationException($\"Can't resolve thisType base type for {thisType}\"),\n                                };\n                            }\n                            else if (matchBaseTypeIndex == -3)\n                            {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs#L200-L236","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the intrinsic declaration so match() arguments point to a different parameter index (never back to the parameter itself)","Give the parameter an explicit concrete type instead of relying on match()","Verify intrinsicDefinition.Parameters and Return in the .sdsl file for missing or self-referencing match() specifiers"],"exampleFix":"// before\nfloat mul(intrin(match(0), match(0)) a);\n// after\nfloat mul(intrin(match(0)) a);","handlingStrategy":"validation","validationCode":"// Before registering the intrinsic, check each parameter/return type is resolvable\nforeach (var p in intrinsicDefinition.Parameters)\n    if (p.Type.Match != null && p.Type.Match.Value.BaseType == ownIndex)\n        throw new InvalidOperationException($\"Intrinsic {name}: parameter matches itself\");","typeGuard":"bool IsResolvable(ParsedType t) => t.BaseType != null && (t.Match == null || t.Match.Value.BaseType != ownIndex);","tryCatchPattern":null,"preventionTips":["Never write match() in an intrinsic declaration that points back to the same parameter","Give intrinsic parameters explicit types where deduction is ambiguous","Test intrinsic expansion in unit coverage for every declared intrinsic"],"tags":["sdsl","shaders","intrinsics","type-resolution"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}