{"record":{"id":"827c2ced7fd2751c","repo":"antlr/antlr4","slug":"missing-interface-implementation","errorCode":null,"errorMessage":"missing interface implementation","messagePattern":"missing interface implementation","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"runtime/JavaScript/src/antlr4/tree/RuleNode.js","lineNumber":10,"sourceCode":"/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved.\n * Use is of this file is governed by the BSD 3-clause license that\n * can be found in the LICENSE.txt file in the project root.\n */\nimport ParseTree from \"./ParseTree.js\";\n\nexport default class RuleNode extends ParseTree {\n\n    get ruleContext() {\n        throw new Error(\"missing interface implementation\")\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":13,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/JavaScript/src/antlr4/tree/RuleNode.js#L1-L13","documentation":"ParseTreePatternMatcher.matchImpl recursively compares a real parse tree against a compiled pattern tree; both must be non-null before any instanceof/structure comparison makes sense. A null tree means the caller asked whether 'nothing' matches a pattern, which is a programming error, so it throws IllegalArgumentException rather than returning false.","triggerScenarios":"Direct calls to the protected matchImpl(tree, patternTree, labels) from a subclass, or a path where the parse result was null (e.g. calling match on a tree reference that was never assigned). Public API matches(tree, pattern, ruleIndex) reaches matchImpl after compiling the pattern, and still throws if tree is null.","commonSituations":"Custom matcher subclasses overriding or delegating to matchImpl; calling pattern.matcher(null).match(...) because a parser step failed upstream and its null result was not checked.","solutions":["Null-check the tree at the call site: only match after a successful parse produced a tree.","Treat parse failure as a distinct outcome (syntax error listener / RecognitionException) instead of proceeding with a null tree.","In subclass overrides, validate parameters before delegating to super.matchImpl."],"exampleFix":"// before\nboolean ok = matcher.matches(null, \"<ID>\", R.expr); // tree == null\n\n// after\nParseTree tree = parser.expr();\nif (tree == null) return; // handle parse failure separately\nboolean ok = matcher.matches(tree, \"<ID>\", R.expr);","handlingStrategy":"validation","validationCode":"if (tree == null) {\n    reportParseFailure();\n    return;\n}\nboolean ok = matcher.matches(tree, patternText, ruleIndex);","typeGuard":"boolean isParsed(ParseTree t) { return t != null; }","tryCatchPattern":null,"preventionTips":["Check parse success (and syntax error listener) before matching.","Never forward possibly-null trees into matching APIs.","In matcher subclasses, validate arguments before calling super.matchImpl."],"tags":["antlr","java","parse-tree-pattern","null-argument","precondition"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}