{"record":{"id":"1828cd67d07f7141","repo":"stride3d/stride","slug":"unsupported-postfix-operator-postfix-operator","errorCode":null,"errorMessage":"Unsupported postfix operator {postfix.Operator}","messagePattern":"Unsupported postfix operator (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs","lineNumber":1461,"sourceCode":"                        }\n\n                        var (builder, context) = compiler;\n\n                        // Emit OpAccessChain with everything so far\n                        EmitOpAccessChain(accessChainIds, i - 1);\n\n                        var resultPointer = result;\n\n                        // This is what this chain return (value before modification)\n                        result = builder.AsValue(context, result);\n\n                        // Use integer so that it gets converted to proper type according to expression type\n                        var constant1 = context.CompileConstant(1);\n                        var modifiedValue = builder.BinaryOperation(table, context, result, postfix.Operator switch\n                        {\n                            Operator.Inc => Operator.Plus,\n                            Operator.Dec => Operator.Minus,\n                            _ => throw new NotSupportedException($\"Unsupported postfix operator {postfix.Operator}\"),\n                        }, constant1, Info);\n\n                        // We store the modified value back in the variable\n                        builder.Insert(new OpStore(resultPointer.Id, modifiedValue.Id, null, []));\n\n                        break;\n                    }\n                default:\n                    throw new NotImplementedException($\"unknown accessor {accessor} on type {currentValueType} in expression {this}\");\n            }\n\n            currentValueType = accessor.Type!;\n            // only if OpAccessChain is emitted (otherwise there is no value)\n            if (compiler != null && accessChainIdCount == 0)\n                intermediateValues![1 + i] = result;\n        }\n\n        if (compiler != null)","sourceCodeStart":1443,"sourceCodeEnd":1479,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs#L1443-L1479","documentation":"Thrown when compiling a postfix increment/decrement expression: only Operator.Inc (mapped to Plus) and Operator.Dec (mapped to Minus) are handled. Any other postfix operator reaching this code path throws NotSupportedException at Expression.cs:1461.","triggerScenarios":"A postfix operator token other than ++ or -- survives parsing and reaches the SPIR-V postfix compilation switch — typically only possible via parser bugs or hand-constructed ASTs.","commonSituations":"Rare in normal shader code; usually encountered after modifying the parser/AST, deserializing an unexpected AST, or an internal compiler invariant break.","solutions":["Replace the offending postfix operator usage in the shader with ++ or --, or rewrite as an explicit assignment (x = x + 1).","Verify the parser only ever produces Inc/Dec postfix operators; fix the parser if another operator leaks through.","If a new postfix operator is intended, add a mapping arm (e.g. to a SPIR-V binary op) in the switch at Expression.cs:1461."],"exampleFix":"// before (internal switch)\n_ => throw new NotSupportedException(...)\n// after\nOperator.Mul => Operator.Times, // example: support the new operator explicitly","handlingStrategy":"try-catch","validationCode":"// ensure only ++/-- postfix operators are produced\nif (postfix.Operator is not (Operator.Inc or Operator.Dec))\n    throw new ShaderCompileHint($\"Postfix {postfix.Operator} not supported\");","typeGuard":"static bool IsSupportedPostfix(Operator op) => op is Operator.Inc or Operator.Dec;","tryCatchPattern":"try { result = CompileExpression(expr, table, compiler); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Unsupported postfix operator\"))\n{ diagnostics.Report(expr.Info, ex.Message); }","preventionTips":["Use ++ and -- as the only postfix operators in shader code.","Rewrite exotic postfix forms as explicit assignments (x = x * 2).","Constrain the parser so only Inc/Dec postfix operators can be constructed."],"tags":["shader","spirv","compiler","operator"],"backgroundTag":"invalid-enum-value","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"}