You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supertypes in ast_nodes.yml can now have a list of fields to expose in the generated QL class. This replaces the previous rule from #22507 where fields that were common among all subtypes were automatically hoisted to supertypes.
Compared to automatic hoisting, manually-declared supertype fields work better in a few scenarios:
There are some subtypes where the field has a more precise type thus failing an exact signature match
Adding a new subtype that lacks a previously-common field can cause a breaking AST change.
Sometimes it's just nice to have getters for fields that are present in the common case, but some subtypes are lacking it.
This PR uses the feature for the callable supertype:
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
The generated unified Callable now declares abstract parameter accessors, but some concrete Callable subtypes don’t implement them, and the generator change likely breaks supertypes that have subtypes but no declared fields.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite Findings: 1 · 1
New issues introduced by this change (2)
Severity
Finding
unified/ql/lib/codeql/unified/internal/Ast.qll — Callable now declares getParameter/getAParameter as abstract, but several concrete…
shared/tree-sitter-extractor/src/generator/ql_gen.rs — compute_exposed_predicates now makes union (supertype) classes expose only the predicates derived…
What changed in this PR
This PR extends the Yeast/unified AST schema format so supertypes can explicitly declare a set of exposed fields, and updates the tree-sitter QL generator and unified AST output to surface those fields (notably callable.parameter) on the generated supertype class.
Changes:
Add a “detailed” supertypes YAML form supporting subtypes + fields, with JSON round-tripping and tests.
Update tree-sitter extractor data structures and QL generator to carry/emit supertype-declared field predicates.
Regenerate unified Ast.qll so Callable exposes parameter accessors and members override them.
Supertypes in ast_nodes.yml can now have a list of fields to expose in the generated QL class. Callable.parameter is then exposed, which was previously not exposed because some callables cannot have parameters, but it's useful to have the getter available anyway.
Detailed supertype fields are not applied to Schema: this loop records only members, while the field registration/type/cardinality loop below visits only yaml.named. As a result, schema_from_yaml/extend_schema_from_yaml return a schema where has_field("callable", Some("parameter")) is false and no declared type or cardinality is available, despite these public helpers documenting that they register all YAML fields. Apply the same field metadata logic to definition.fields() and add a schema-path assertion to the new test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supertypes in
ast_nodes.ymlcan now have a list of fields to expose in the generated QL class. This replaces the previous rule from #22507 where fields that were common among all subtypes were automatically hoisted to supertypes.Compared to automatic hoisting, manually-declared supertype fields work better in a few scenarios:
This PR uses the feature for the
callablesupertype:Previously the
bodyfield was hoisted automatically, but notparameter,because some callables can't have parameters (like top-level).