stride3d/stride · error · Exception

kind is inexistent

Error message

kind is inexistent

What it means

OperandEnumerator.MoveNext walks the SPIR-V instruction operand words against the grammar's logical operand descriptions. When a logical operand descriptor has no Kind (null), the enumerator cannot know how many words it consumes, so it throws this Exception. This indicates a malformed or incomplete operand descriptor for the opcode being parsed.

Solutions

  1. Regenerate/repair the SPIR-V grammar tables (Grammar/JsonGrammar generation) so every logical operand has a Kind
  2. Check the opcode of the failing instruction against the SPIRV-LS grammar for missing operand definitions
  3. Wrap instruction parsing in try/catch and log the opcode to identify the grammar gap
  4. Update the Stride SPIR-V specification bindings to the version matching the module being parsed

Example fix

// before
else if (Pairs.Contains(logOp.Kind ?? throw new Exception("kind is inexistent")))
    wid += 2;
// after
if (logOp.Kind is not { } kind)
    throw new InvalidOperationException($"Operand {oid} of opcode {opcode} has no Kind in the grammar");
else if (Pairs.Contains(kind))
    wid += 2;
Defensive patterns

Strategy: validation

Validate before calling

if (logOp.Kind is null)
    throw new InvalidOperationException($"Grammar descriptor for operand {oid} has no Kind");

Type guard

bool HasKind(OperandInfo op) => op.Kind.HasValue;

Prevention

When it happens

Trigger: Iterating operands of a SPIR-V instruction whose grammar entry contains a logical operand with Kind == null and Quantifier that is not One (the null Kind check is hit in the ZeroOrOne/ZeroOrMore/logical-else branches via Pairs.Contains(logOp.Kind ?? throw ...)).

Common situations: Parsing SPIR-V modules produced by newer or non-standard toolchains whose opcodes are not in the generated grammar tables; a codegen bug in the grammar-to-C# generation leaving Kind unset; manually constructed OperandInfo with missing Kind.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/fd80fb2b6aaa0db6. Report an issue: GitHub.

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Spirv/Parsing/OperandEnumerator.cs:42

            if (logicalOperands[0].Kind == OperandKind.None)
                return false;
            return true;
        }
        else if (oid >= logicalOperands.Count - 1)
            return false;
        else
        {
            var logOp = logicalOperands[oid];

            if (logOp.Quantifier == OperandQuantifier.One)
            {
                if (logOp.Kind == OperandKind.LiteralString)
                {
                    while (!Operands[wid].HasEndString())
                        wid += 1;
                    wid += 1;
                }
                else if (Pairs.Contains(logOp.Kind ?? throw new Exception("kind is inexistent")))
                    wid += 2;
                else
                    wid += 1;
                oid += 1;

            }
            else if (logOp.Quantifier == OperandQuantifier.ZeroOrOne)
            {
                if (
                    Pairs.Contains(logOp.Kind ?? throw new Exception("kind is inexistent"))
                    && wid < Operands.Length - 1
                )
                {
                    wid += 2;
                }
                else if (
                    logOp.Kind == OperandKind.LiteralString
                    && wid < Operands.Length

View on GitHub (pinned to 96fad776d2)