{"record":{"id":"e708e313092a4cd6","repo":"stride3d/stride","slug":"couldn-t-handle-operand-kind-logop-kind","errorCode":null,"errorMessage":"Couldn't handle operand kind {logOp.Kind}","messagePattern":"Couldn't handle operand kind (.+?)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Spirv/Parsing/OpDataEnumerator.cs","lineNumber":145,"sourceCode":"\n        }\n    }\n\n    public SpvOperand ParseCurrent()\n    {\n        var logOp = logicalOperands[oid];\n\n        return logOp switch\n        {\n            { Parameters: OperandParameters { Count: > 0 } } when pid == -1 =>\n                new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 1), wid, true),\n            { Parameters: OperandParameters { Count: > 0 } p } when p.ContainsKey(new(logOp.Kind ?? OperandKind.None, Operands[startOperand])) && pid < p[new(logOp.Kind ?? OperandKind.None, Operands[startOperand])].Length =>\n            p[new(logOp.Kind ?? OperandKind.None, Operands[startOperand])][pid] switch\n            {\n                { Name: string n, Kind: OperandKind k } when k.ToString().StartsWith(\"Pair\") => new(n, k, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 2), wid),\n                { Name: string n, Kind: OperandKind.LiteralString } => new(n, OperandKind.LiteralString, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, Operands[wid..].LengthOfString()), wid),\n                { Name: string n, Kind: OperandKind k } => new(n, k, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 1), wid),\n                _ => throw new NotImplementedException($\"Couldn't handle operand kind {logOp.Kind}\")\n            },\n            { Quantifier: OperandQuantifier.One, Kind: OperandKind.PairIdRefIdRef or OperandKind.PairIdRefLiteralInteger or OperandKind.PairLiteralIntegerIdRef } l\n                => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 2), wid),\n            { Quantifier: OperandQuantifier.One, Kind: OperandKind.LiteralString } => new(logOp.Name, OperandKind.LiteralString, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, Operands[wid..].LengthOfString()), wid),\n            { Quantifier: OperandQuantifier.One, Kind: _ } => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 1), wid),\n            { Quantifier: OperandQuantifier.ZeroOrOne, Kind: OperandKind.PairIdRefIdRef or OperandKind.PairIdRefLiteralInteger or OperandKind.PairLiteralIntegerIdRef }\n                => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 2), wid),\n            { Quantifier: OperandQuantifier.ZeroOrOne, Kind: OperandKind.LiteralString }\n                => new(logOp.Name, OperandKind.LiteralString, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, Operands[wid..].LengthOfString()), wid),\n            { Quantifier: OperandQuantifier.ZeroOrOne, Kind: _ }\n                => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, wid < Operands.Length ? Operands.Slice(wid, 1) : []),\n            { Quantifier: OperandQuantifier.ZeroOrMore, Kind: OperandKind.PairIdRefIdRef or OperandKind.PairIdRefLiteralInteger or OperandKind.PairLiteralIntegerIdRef }\n                => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, wid < Operands.Length ? Operands[wid..] : [], wid),\n            { Quantifier: OperandQuantifier.ZeroOrMore, Kind: OperandKind.LiteralString }\n                => throw new Exception(\"params of strings is not yet implemented\"),\n            { Quantifier: OperandQuantifier.ZeroOrMore, Kind: _ }\n                => new(logOp.Name, logOp.Kind ?? OperandKind.None, logOp.Quantifier ?? OperandQuantifier.One, wid < Operands.Length ? Operands[wid..] : [], wid),\n            _ => throw new NotImplementedException()","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Spirv/Parsing/OpDataEnumerator.cs#L127-L163","documentation":"ParseCurrent materializes the current operand as (name, kind, words slice). Within a parameters table (Count > 0), the inner switch handles Pair* kinds, LiteralString, and generic kinds; anything else — a null/unknown kind not present in the parameters dictionary resolution, or a parameter entry with no matched arm — throws. Called by Current for each operand.","triggerScenarios":"Parsing an instruction whose operand parameters table contains an entry whose Kind is neither a Pair* kind nor LiteralString nor a plain recognized kind — i.e. logOp.Kind resolves to null/OperandKind.None or an exotic kind inside the parameters path.","commonSituations":"New SPIR-V grammar versions introducing operand kinds the parser's switch doesn't enumerate; entries in the parameters dictionary with unset Kind fields; modules using extensions with custom operand kinds.","solutions":["Inspect logOp.Kind at the throw and add a switch arm for it (e.g. LiteralContextDependentNumber or other exotic kinds).","Update embedded grammar/OpData tables to the SPIR-V spec version matching the input module.","Validate the module with spirv-val; if it's invalid, fix the producing toolchain instead.","Patch ParseCurrent to fall back to consuming a single word for unknown kinds instead of throwing, if lossy parsing is acceptable."],"exampleFix":"// before\n_ => throw new NotImplementedException($\"Couldn't handle operand kind {logOp.Kind}\")\n// after\n{ Kind: OperandKind.LiteralContextDependentNumber } => new(n, k, logOp.Quantifier ?? OperandQuantifier.One, Operands.Slice(wid, 1), wid),\n_ => throw new NotImplementedException($\"Couldn't handle operand kind {logOp.Kind}\")","handlingStrategy":"try-catch","validationCode":"// verify the operand kind is one ParseCurrent handles:\nif (logOp.Kind is null or OperandKind.None)\n    throw new NotSupportedException(\"Operand kind not populated in grammar tables\");","typeGuard":"static bool IsParsableKind(OperandKind? k) => k is OperandKind.LiteralString\n    or OperandKind.PairIdRefIdRef or OperandKind.PairIdRefLiteralInteger\n    or OperandKind.PairLiteralIntegerIdRef or not null and not OperandKind.None;","tryCatchPattern":"try { var operand = enumerator.Current; }\ncatch (NotImplementedException ex) when (ex.Message.StartsWith(\"Couldn't handle operand kind\")) { /* skip or manually parse this operand; record the kind */ }","preventionTips":["Regenerate OpData tables from the same spirv.core.grammar.json version as the target modules.","Check parameters dictionary entries for null Kind before enumeration.","Reject or special-case extension/custom operand kinds before parsing."],"tags":["spirv","parsing","operand-kind","grammar"],"backgroundTag":"method-not-implemented","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}