-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruby printAst: fix order for synth children of real parents #19448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8341f88
to
ed8f10f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that synthesized AST children under real (non-synthesized) parents receive the correct index instead of defaulting to zero, making graph output deterministic.
- Update expected AST print output to reflect the new child ordering
- Revise
getSynthAstNodeIndex
logic to compute and assign the correct index when a real parent has synthesized children
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
ruby/ql/test/library-tests/ast/Ast.expected | Adjusted expected lines to match reordered synth children |
ruby/ql/lib/codeql/ruby/printAst.qll | Changed getSynthAstNodeIndex to use if /then for proper index lookup |
Comments suppressed due to low confidence (1)
ruby/ql/lib/codeql/ruby/printAst.qll:123
- Consider adding a test case where a real parent has multiple synthesized children to verify that each child gets a unique, deterministic index instead of defaulting to zero.
private int getSynthAstNodeIndex() {
I think this is quite subtle. Note that printAST results are shown to the user in the ide so this is about more than just the tests. It was explicitly written this way in #12612 . The other tests that change originally had the right order and are now incorrect. |
By that do you mean the changes in this PR? As an alternative, I could leave the synth order the same and use toString() as a final disambiguator as in that PR. I don't see any test changes from this other than the Ast.ql output. |
I mean the change where the |
@alexet Ok, I think I have something more precise now, but I agree, this might have more implications than the tests capture. |
Real parents can have synthesized children, so always assigning index 0 leads to nondeterminism in graph output.
This counteracts the movement of synth children away from the node from which they take their location, following the decision to take the index of synth children of real parents into account.
…nth index in real parent This prevents a bunch of unrelated movements in AstDesugar.ql
09faa23
to
83edc8e
Compare
83edc8e
to
e9d5515
Compare
Real parents can have synthesized children, so always assigning index 0 leads to nondeterminism in graph output.