{"record":{"id":"9a84e52c8b0005ec","repo":"mono/mono","slug":"s-1-rule-never-reduced","errorCode":null,"errorMessage":"%s: 1 rule never reduced\n","messagePattern":"(.+?): 1 rule never reduced\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mcs/jay/mkpar.c","lineNumber":249,"sourceCode":"\trules_used[i] = 0;\n\n    for (i = 0; i < nstates; ++i)\n    {\n\tfor (p = parser[i]; p; p = p->next)\n\t{\n\t    if (p->action_code == REDUCE && p->suppressed == 0)\n\t\trules_used[p->number] = 1;\n\t}\n    }\n\n    nunused = 0;\n    for (i = 3; i < nrules; ++i)\n\tif (!rules_used[i]) ++nunused;\n\n    if (nunused)\n    {\n\tif (nunused == 1)\n\t    fprintf(stderr, \"%s: 1 rule never reduced\\n\", myname);\n\telse\n\t    fprintf(stderr, \"%s: %d rules never reduced\\n\", myname, nunused);\n     }\n}\n\nstatic void\nremove_conflicts (void)\n{\n    register int i;\n    register int symbol;\n    register action *p, *pref;\n\n    SRtotal = 0;\n    RRtotal = 0;\n    SRconflicts = NEW2(nstates, short);\n    RRconflicts = NEW2(nstates, short);\n    for (i = 0; i < nstates; i++)\n    {","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mcs/jay/mkpar.c#L231-L267","documentation":"Emitted by unused_rules() in mcs/jay/mkpar.c:249 (singular branch) when exactly one grammar rule is never selected as a reduction in any parser state. After building LALR tables, jay scans every state's actions; a rule whose `rules_used` entry stays 0 is unreachable from the start symbol, so it can never fire. It is a warning — generation completes, but the rule is dead weight.","triggerScenarios":"A production that is not reachable from the start symbol via any chain of nonterminals, leaving exactly one such rule.","commonSituations":"Leftover experimental productions after refactoring; a nonterminal defined but never referenced; an alternative superseded by another rule.","solutions":["Delete the unreachable production, or reference its LHS nonterminal from a reachable rule.","If the rule is intended, connect it to the start symbol's derivation.","Re-run jay; a clean run confirms no unreachable rules remain."],"exampleFix":"// before\nstart : a ;\na : 'x' ;\nb : 'y' ;   /* b never reached -> 1 rule never reduced */\n// after\nstart : a ;\na : 'x' ;","handlingStrategy":"validation","validationCode":"# Build with -v and assert the unused-rule warning is absent from stderr.\njay -v -c -o Parser.cs grammar.jay 2>jay.log\ngrep -q 'rule never reduced' jay.log && { echo 'unreachable rule detected'; cat jay.log; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After refactoring, re-run jay and confirm no 'rule never reduced' lines.","Delete or reconnect productions whose LHS is unreachable from the start symbol.","Treat the unused-rule warning as a CI failure."],"tags":["jay","grammar","unreachable","rules","lalr"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}