{"record":{"id":"c782bbd6415a31c9","repo":"stride3d/stride","slug":"unsupported-type-currentvaluetype-for-non-pointer-indexer","errorCode":null,"errorMessage":"Unsupported type {currentValueType} for non-pointer indexer","messagePattern":"Unsupported type (.+?) for non-pointer indexer","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs","lineNumber":1409,"sourceCode":"                        }\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),\n                                VectorType v => v.BaseType,\n                                ArrayType a => a.BaseType,\n                                _ => throw new NotSupportedException($\"Unsupported type {currentValueType} for non-pointer indexer\"),\n                            }, Specification.StorageClass.Function);\n                            break;\n                        }\n\n                        // We need to load as a variable to use OpAccessChain\n                        var (builder, context) = compiler;\n                        var ptrType = context.GetOrRegister(new PointerType(currentValueType, Specification.StorageClass.Function));\n                        var functionVariable = builder.AddFunctionVariable(ptrType, context.Bound++);\n                        builder.Insert(new OpStore(functionVariable, result.Id, null, []));\n                        result = new SpirvValue(functionVariable, ptrType);\n                        // Process again the same item with new type\n                        var indexerValue = indexer.Index.CompileAsValue(table, compiler);\n                        PushAccessChainId(accessChainIds, indexerValue.Id);\n                        break;\n                    }\n                case (PointerType { BaseType: PatchType { BaseType: var t } } p, IndexerExpression indexer):\n                    {\n                        if (compiler == null)","sourceCodeStart":1391,"sourceCodeEnd":1427,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs#L1391-L1427","documentation":"Thrown when compiling a non-pointer indexer: the current value type being indexed must be a matrix (yields a vector), a vector (yields a scalar), or an array (yields its element type). Any other type reaching the indexer — e.g. a struct or scalar — falls through the switch and throws this NotSupportedException at Expression.cs:1409.","triggerScenarios":"Using `expr[index]` where expr's inferred type is not MatrixType, VectorType, or ArrayType (scalar, struct, bool, custom type) during SPIR-V compilation.","commonSituations":"Subscripting a struct or scalar in shader code, mistyping a variable so the compiler infers the wrong kind, or hitting a newly added SDSL type that the indexer path was never extended for.","solutions":["Fix the shader expression so only vectors, matrices, or arrays are subscripted.","Check the inferred currentValueType by simplifying the expression or adding compiler diagnostics, and correct the variable declaration.","If a new type must support indexing, add a mapping arm to the switch at Expression.cs:1409 that produces the element type."],"exampleFix":"// before\nfloat x = 1.0; float v = x[0];        // scalar indexed\n// after\nfloat1 xs = float1(1.0); float v = xs[0];  // or use a vector/matrix/array type","handlingStrategy":"type-guard","validationCode":"// validate the indexed expression's inferred type before subscripting\nif (value is not (MatrixType or VectorType or ArrayType))\n    throw new ShaderCompileHint($\"Cannot index value of type {value.GetType().Name}\");","typeGuard":"static bool IsIndexable(BaseType t) => t is MatrixType or VectorType or ArrayType;","tryCatchPattern":"try { result = CompileExpression(expr, table, compiler); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"for non-pointer indexer\"))\n{ diagnostics.Report(expr.Info, ex.Message); }","preventionTips":["Subscript only vectors, matrices, and arrays in SDSL code.","Check variable declarations when inference surprises you.","Add compiler tests covering indexing of every declared type kind."],"tags":["shader","spirv","compiler","type-mismatch"],"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"}