{"record":{"id":"706c081e7484bccc","repo":"antlr/antlr4","slug":"couldn-t-identify-final-state-of-the-precedence-ru-706c08","errorCode":null,"errorMessage":"Couldn't identify final state of the precedence rule prefix section.","messagePattern":"Couldn't identify final state of the precedence rule prefix section\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"runtime/CSharp/src/Atn/ATNDeserializer.cs","lineNumber":135,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!(state_3 is StarLoopEntryState))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tATNState maybeLoopEndState = state_3.Transition(state_3.NumberOfTransitions - 1).target;\n\t\t\t\t\t\tif (!(maybeLoopEndState is LoopEndState))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (maybeLoopEndState.epsilonOnlyTransitions && maybeLoopEndState.Transition(0).target is RuleStopState)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tendState = state_3;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (endState == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new NotSupportedException(\"Couldn't identify final state of the precedence rule prefix section.\");\n\t\t\t\t\t}\n\t\t\t\t\texcludeTransition = ((StarLoopEntryState)endState).loopBackState.Transition(0);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tendState = atn.ruleToStopState[i_13];\n\t\t\t\t}\n\t\t\t\t// all non-excluded transitions that currently target end state need to target blockEnd instead\n\t\t\t\tforeach (ATNState state_4 in atn.states)\n\t\t\t\t{\n\t\t\t\t\tforeach (Transition transition in state_4.transitions)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (transition == excludeTransition)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (transition.target == endState)\n\t\t\t\t\t\t{","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/CSharp/src/Atn/ATNDeserializer.cs#L117-L153","documentation":"While preprocessing a left-recursive rule's ATN, the deserializer scans the star-loop states of the precedence-rule prefix section to find its end state (a LoopEndState whose first transition targets a RuleStopState). If no candidate matches, the serialized ATN does not have the expected shape and NotSupportedException is thrown — effectively a data/version corruption signal.","triggerScenarios":"Deserializing serialized ATN data produced by a different ANTLR version or tampered/truncated; a left-recursive rule's generated ATN not matching the C# runtime's expectations.","commonSituations":"Antlr4.Runtime NuGet version differing from the code generator version, stale generated .cs files after an upgrade, or hand-crafted ATN byte arrays.","solutions":["Regenerate all parsers/lexers with the tool version matching the Antlr4.Runtime package and rebuild","Remove stale generated files and bin/obj so no old serialized ATN survives","Verify only one consistent ANTLR version is referenced across the solution"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { new ATNDeserializer().Deserialize(data); } catch (NotSupportedException e) { /* ATN shape unrecognized: regenerate parsers with matching tool/runtime version */ }","preventionTips":["Pin codegen and runtime to the same ANTLR version","Regenerate all grammars and clean outputs after any ANTLR upgrade"],"tags":["antlr","atn","version-mismatch","csharp"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}