Fix copy-paste bugs in DataflowAnalyzer equality checks#44572
Conversation
📝 WalkthroughWalkthroughCorrects two copy-paste bugs in the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java (1)
1393-1393: Correct fix for GROUP_EXPR equality.Casting
nodeBhere ensuresequality(groupExprA.expression, groupExprB.expression)recurses into both operands rather than comparingnodeAwith itself. Consistent with theTYPE_CONVERSION_EXPR/UNARY_EXPRcases above.A small follow-up worth considering (out of scope for this PR): adding a regression test under the dataflow analyzer test suite that constructs a
tableliteral with two records whose keys differ only inside anXML_QNAMEorGROUP_EXPRsubexpression, to lock in this behavior and prevent re-introduction.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java` at line 1393, The GROUP_EXPR branch in DataflowAnalyzer's equality logic incorrectly compares the node to itself; cast nodeB to BLangGroupExpr (BLangGroupExpr groupExprB = (BLangGroupExpr) nodeB) and call equality(groupExprA.expression, groupExprB.expression) so the comparison recurses into the two operands correctly (mirroring the TYPE_CONVERSION_EXPR/UNARY_EXPR cases).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java`:
- Line 1393: The GROUP_EXPR branch in DataflowAnalyzer's equality logic
incorrectly compares the node to itself; cast nodeB to BLangGroupExpr
(BLangGroupExpr groupExprB = (BLangGroupExpr) nodeB) and call
equality(groupExprA.expression, groupExprB.expression) so the comparison
recurses into the two operands correctly (mirroring the
TYPE_CONVERSION_EXPR/UNARY_EXPR cases).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4559aff9-18dd-49c8-9569-709ec9d99d77
📒 Files selected for processing (1)
compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44572 +/- ##
============================================
- Coverage 75.03% 75.02% -0.01%
Complexity 58707 58707
============================================
Files 3601 3601
Lines 227161 227161
Branches 29581 29581
============================================
- Hits 170443 170437 -6
- Misses 47215 47217 +2
- Partials 9503 9507 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Purpose
Fixes #44571
Two equality checks in
DataflowAnalyzer.javaincorrectly comparednodeAwith itself, causing theXML_QNAMEandGROUP_EXPRchecks to always return true. This PR corrects them to comparenodeAwithnodeB.Approach
XML_QNAME):nodeA == nodeA→nodeA == nodeBGROUP_EXPR):nodeA == nodeA→nodeA == nodeBCheck List
Summary
This pull request corrects two copy-paste errors in the
DataflowAnalyzer.javaequality comparison method where the second operand of the comparison was incorrectly referencing the first operand instead of the intended second operand.The fixes ensure that equality checks for
XML_QNAMEandGROUP_EXPRnode types properly compare both operands as intended, rather than comparing each operand against itself. This improves the correctness and reliability of the dataflow analysis by ensuring equality comparisons work as designed.Changes made:
nodeBinstead ofnodeAnodeBinstead ofnodeA