Ruby AST: preserve ExceptionList node in RescueClause for 2+ exceptions#22014
Open
Copilot wants to merge 4 commits into
Open
Ruby AST: preserve ExceptionList node in RescueClause for 2+ exceptions#22014Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
Ruby AST: Add ExceptionList node for rescue clauses with 2+ exceptions
Ruby AST: preserve ExceptionList node in RescueClause for 2+ exceptions
Jun 19, 2026
Copilot created this pull request from a session on behalf of
aschackmull
June 19, 2026 09:51
View session
946b770 to
6fbb572
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Ruby AST modeling to preserve the intermediate tree-sitter Exceptions node for rescue clauses that specify two or more exception types, by introducing a new ExceptionList AST node. This helps maintain the original syntactic structure instead of flattening exception types directly under RescueClause.
Changes:
- Introduces a new
ExceptionListAST node forrescueclauses with 2+ exceptions and exposes it viaRescueClause.getExceptions(). - Updates
RescueClause.getException(int)to remain usable across 0/1/2+ exception cases by delegating throughExceptionListfor 2+. - Extends library tests/fixtures to include a
rescueclause with multiple exceptions and updates expected outputs accordingly.
Show a summary per file
| File | Description |
|---|---|
| ruby/ql/lib/codeql/ruby/ast/internal/AST.qll | Adds internal TExceptionList node kind and wires it into the generated AST node sets. |
| ruby/ql/lib/codeql/ruby/ast/Expr.qll | Introduces ExceptionList and updates RescueClause APIs/child edges for 2+ exceptions. |
| ruby/ql/test/library-tests/ast/calls/calls.rb | Adds a begin … rescue foo, X::bar … ensure … end fixture to exercise the 2+ exception case. |
| ruby/ql/test/library-tests/ast/Ast.expected | Updates printed AST expectations to include the new ExceptionList node/edge. |
| ruby/ql/test/library-tests/ast/TreeSitter.expected | Updates tree-sitter parse-tree expectations for the modified fixture file layout. |
| ruby/ql/test/library-tests/ast/ValueText.expected | Updates constant-value expectations due to fixture line shifts. |
| ruby/ql/test/library-tests/ast/calls/calls.expected | Updates call expectations due to fixture line shifts/new construct. |
| ruby/ql/test/library-tests/ast/calls/arguments.expected | Updates argument expectations due to fixture line shifts. |
| ruby/ql/test/library-tests/ast/AstDesugar.expected | Updates desugaring expectations due to fixture line shifts. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 0
aschackmull
approved these changes
Jun 19, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
RescueClausepreviously flattened all exception types as direct children, discarding the intermediateExceptionstree-sitter node. For 2+ exceptions, a newExceptionListAST node now preserves that structure.Behavior
getException(0)ExceptionListis a direct child viagetExceptions(); individual exceptions accessed viaExceptionList.getException(n)RescueClause.getException(int n)andgetAnException()remain usable for all cases (delegates throughExceptionListfor 2+). The CFG is unaffected.Changes
AST.qll: AddedTExceptionList(Ruby::Exceptions g)(only whenstrictcount > 1); added toTAstNodeReal,toGenerated, andTExprExpr.qll: NewExceptionListclass withgetException(int n);RescueClause.getExceptiondelegates throughExceptionListfor 2+ case; newRescueClause.getExceptions();getAChildupdated to exposeExceptionListas the tree edge for 2+ case