{"record":{"id":"a21006f784ba8e71","repo":"stride3d/stride","slug":"can-t-resolve-thistype-base-type-for-thistype","errorCode":null,"errorMessage":"Can't resolve thisType base type for {thisType}","messagePattern":"Can't resolve thisType base type for (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs","lineNumber":232,"sourceCode":"                        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                            {\n                                // Match funcT base type\n                                parameterTypeHelper[index].BaseType = thisType switch\n                                {\n                                    ByteAddressBufferType => ScalarType.UInt,\n                                    null => throw new ArgumentNullException(nameof(thisType)),\n                                    _ => throw new NotImplementedException($\"$funcT not supported for {thisType}\"),\n                                };\n                            }\n                            else\n                            {\n                                parameterTypeHelper[index].BaseType = parameterTypeHelper[matchBaseTypeIndex].BaseType;\n                            }\n                        }\n                    }","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs#L214-L250","documentation":"The expander tried to derive a parameter's base type from the intrinsic's thisType (the object a member-style intrinsic is called on), but the thisType's kind has no defined element/base type mapping in the switch. Only texture, buffer and structured-buffer style types are supported there.","triggerScenarios":"An intrinsic template whose parameter match index is -1 (match thisType's base type) is invoked with a thisType that is a scalar, vector, matrix, or other type without an element type.","commonSituations":"Calling a buffer/texture-only intrinsic on a plain scalar or vector variable; SDSL files where an intrinsic meant for StructuredBuffer is applied to arrays.","solutions":["Call the intrinsic only on supported thisTypes (Texture*, Buffer/StructuredBuffer, Append/ConsumeStructuredBuffer)","If you own the intrinsic declaration, restrict it (e.g. with a type constraint) so it cannot bind to unsupported thisTypes","Extend the switch in IntrinsicTemplateExpander if a new buffer-like type must be supported upstream"],"exampleFix":"// before\nuint len = myArray.GetLength(); // myArray is float[]\n// after\nuint len = myStructuredBuffer.GetLength(); // StructuredBuffer<float>","handlingStrategy":"type-guard","validationCode":"// Ensure the receiver type has a derivable element/base type before calling buffer/texture intrinsics\nif (value is not TextureType and not BufferType and not StructuredBufferType and not AppendStructuredBufferType and not ConsumeStructuredBufferType)\n    throw new InvalidOperationException($\"{value} has no base type for this intrinsic\");","typeGuard":"bool HasBaseType(TypeBase t) => t is TextureType or BufferType or StructuredBufferType or AppendStructuredBufferType or ConsumeStructuredBufferType;","tryCatchPattern":"try { Expand(intrinsic, thisType); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Can't resolve thisType base type\")) { /* report call-site type mismatch */ }","preventionTips":["Only call resource intrinsics on texture/buffer-typed values","Add type constraints to intrinsic declarations","Keep a checklist of which thisTypes each intrinsic supports"],"tags":["sdsl","shaders","this-type","type-resolution"],"backgroundTag":"type-mismatch","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"}