{"record":{"id":"69d333a41005ced8","repo":"stride3d/stride","slug":"unsupported-base-type-p-basetype-for-indexer","errorCode":null,"errorMessage":"Unsupported base type {p.BaseType} for indexer","messagePattern":"Unsupported base type (.+?) for indexer","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs","lineNumber":1388,"sourceCode":"                            indexer.Index.ProcessSymbol(table);\n                            accessor.Type = new PointerType(t, p.StorageClass);\n                            break;\n                        }\n                        var indexerValue = indexer.Index.CompileAsValue(table, compiler);\n                        PushAccessChainId(accessChainIds, indexerValue.Id);\n                        break;\n                    }\n                // Array indexer for vector/matrix\n                case (PointerType { BaseType: VectorType or MatrixType } p, IndexerExpression indexer):\n                    {\n                        if (compiler == null)\n                        {\n                            indexer.Index.ProcessSymbol(table);\n                            accessor.Type = new PointerType(p.BaseType switch\n                            {\n                                MatrixType m => new VectorType(m.BaseType, m.Rows),\n                                VectorType v => v.BaseType,\n                                _ => throw new NotSupportedException($\"Unsupported base type {p.BaseType} for indexer\"),\n                            }, p.StorageClass);\n                            break;\n                        }\n\n                        var indexerValue = indexer.Index.CompileAsValue(table, compiler);\n                        PushAccessChainId(accessChainIds, indexerValue.Id);\n                        break;\n                    }\n                // For indexer accessor into non pointer types, we can't use OpCompositeExtract (it expects a constant)\n                // So we load the value into a variable and use normal path\n                case (ArrayType or VectorType or MatrixType, IndexerExpression indexer):\n                    {\n                        if (compiler == null)\n                        {\n                            indexer.Index.ProcessSymbol(table);\n                            accessor.Type = new PointerType(currentValueType switch\n                            {\n                                MatrixType m => new VectorType(m.BaseType, m.Rows),","sourceCodeStart":1370,"sourceCodeEnd":1406,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs#L1370-L1406","documentation":"Thrown by the SDSL-to-SPIR-V expression compiler when an indexer accesses a pointer parameter whose base type is neither a matrix nor a vector. The compiler can only derive the pointed-to element type (matrix -> element vector, vector -> scalar) for those shapes, so any other base type hits the switch default and this NotSupportedException is thrown at Expression.cs:1388.","triggerScenarios":"Indexing into a pointer whose pointee is not MatrixType or VectorType (e.g. a pointer to an array, struct, or scalar) inside a SPIR-V compilation of an SDSL expression with `compiler != null`.","commonSituations":"Writing shader code that subscripts a pointer parameter bound to a non-vector/matrix type, or after type-inference changes make a pointer's BaseType an unexpected kind (array/struct) — often after refactors of the SDSL type system or unusual buffer declarations.","solutions":["Change the shader code so the indexed pointer refers to a vector or matrix (e.g. index the variable before taking a pointer, or declare the buffer element as a vector/matrix).","If arrays/structs must be indexable through pointers, extend the switch in Expression.cs to map ArrayType => a.BaseType (mirroring the non-pointer case at line 1409) and rebuild.","Inspect the offending parameter's declared type in the shader to confirm what BaseType actually resolves to and why."],"exampleFix":"// before (shader)\nStructuredBuffer<int> data;\n... ptr = &data; ptr[i] ...   // base type is array/other\n// after\n// index the buffer variable directly, or make the pointer point at a vector/matrix element","handlingStrategy":"type-guard","validationCode":"// before indexing a pointer, check its pointee kind in the AST\nif (param.BaseType is not MatrixType and not VectorType)\n    throw new ShaderCompileHint($\"Cannot index pointer to {param.BaseType}; use vector/matrix\");","typeGuard":"static bool IsIndexablePointer(Parameter p) => p.BaseType is MatrixType or VectorType;","tryCatchPattern":"try { result = CompileExpression(expr, table, compiler); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Unsupported base type\"))\n{ diagnostics.Report(expr.Info, ex.Message); }","preventionTips":["Only take pointers to vector or matrix values in shader code.","Index variables directly instead of subscripting through pointers.","Keep a unit test compiling shaders that index each supported buffer element type."],"tags":["shader","spirv","compiler","unsupported-type"],"backgroundTag":"unsupported-operation","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"}