{"record":{"id":"38a1f51b89a363ad","repo":"tree-sitter/tree-sitter","slug":"supertype-rule-symbol-symbol-name-is-not-de","errorCode":null,"errorMessage":"Supertype rule \\`${symbol.symbol.name}\\` is not defined.","messagePattern":"Supertype rule \\\\`(.+?)\\\\` is not defined\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/generate/src/dsl.js","lineNumber":450,"sourceCode":"    }).map(symbol => symbol.name);\n  }\n\n  let supertypes = baseGrammar.supertypes;\n  if (options.supertypes) {\n    if (typeof options.supertypes !== \"function\") {\n      throw new Error(\"Grammar's 'supertypes' property must be a function.\");\n    }\n\n    const baseSupertypeRules = baseGrammar.supertypes.map(sym);\n    const supertypeRules = options.supertypes.call(ruleBuilder, ruleBuilder, baseSupertypeRules);\n\n    if (!Array.isArray(supertypeRules)) {\n      throw new Error(\"Grammar's supertypes must be an array of rules.\");\n    }\n\n    supertypes = supertypeRules.map(symbol => {\n      if (symbol.name === 'ReferenceError') {\n        throw new Error(`Supertype rule \\`${symbol.symbol.name}\\` is not defined.`);\n      }\n      return symbol.name;\n    });\n  }\n\n  let precedences = baseGrammar.precedences;\n  if (options.precedences) {\n    if (typeof options.precedences !== \"function\") {\n      throw new Error(\"Grammar's 'precedences' property must be a function\");\n    }\n    precedences = options.precedences.call(ruleBuilder, ruleBuilder, baseGrammar.precedences);\n    if (!Array.isArray(precedences)) {\n      throw new Error(\"Grammar's precedences must be an array of arrays of rules.\");\n    }\n    precedences = precedences.map(list => {\n      if (!Array.isArray(list)) {\n        throw new Error(\"Grammar's precedences must be an array of arrays of rules.\");\n      }","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/tree-sitter/tree-sitter/blob/dff1fd868c750dbbae179fcd5c43ce987e4e0528/crates/generate/src/dsl.js#L432-L468","documentation":"While mapping the supertypes array, the DSL detects its undefined-rule sentinel: accessing an unknown name on the rule-builder Proxy returns a ReferenceError object that carries the missing rule name on `.symbol.name`, and that name is interpolated into this message. Unlike `inline`, where unknown rules only log warnings, an undefined supertype is a hard error because supertypes shape node visibility in queries.","triggerScenarios":"`supertypes: $ => [$.statment]` — a typo for `statement`. Referencing a rule that exists only in a grammar that was not inherited with `grammar(base, {...})`.","commonSituations":"Renaming rules without updating the supertypes list. Dialect grammars assuming a base rule the base grammar never defined.","solutions":["Read the rule name from the message and compare it letter-by-letter with your `rules` keys.","Fix the typo, or define the rule in this grammar or in the inherited base.","Re-run `tree-sitter generate`."],"exampleFix":"// before\nsupertypes: $ => [$.statment] // typo\n\n// after\nsupertypes: $ => [$.statement]","handlingStrategy":"validation","validationCode":"const SUPER = ['expression', 'type'];\nconst ruleNames = new Set(Object.keys(rules)); // your rules object literal\nfor (const name of SUPER) {\n  if (!ruleNames.has(name)) {\n    throw new Error(`supertype '${name}' is not defined`);\n  }\n}\n// then use: supertypes: $ => SUPER.map(n => $[n]),","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define supertype names in one array and reuse it for both rules and the option.","Grep for stale names after renames.","Run `tree-sitter generate` in CI."],"tags":["tree-sitter","grammar-dsl","supertypes","undefined-rule"],"backgroundTag":"undefined-rule-reference","analyzedSha":"dff1fd868c750dbbae179fcd5c43ce987e4e0528","analyzedAt":"2026-08-16T22:01:49.632Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}