fix(scanner): loop Pass B to a fixed point, closing issue #18#23
Merged
Conversation
Pass B (composite-literal field binding) ran as a single forward sweep over parsed files sorted by relative path, not a fixed-point iteration — a theoretical order-dependence risk flagged during independent review of #14, before merge (not a demonstrated real-world miss). Changed to loop until a full sweep discovers nothing new, capped at len(parsed)+1 sweeps as a safety bound a real fixed point can never reach (a genuine wrapper-of-wrapper chain can't legitimately be deeper than the number of files in the scan). Honest note on scope: while investigating a regression fixture for this, I could not construct a reachable repro matching the issue's own illustrative example with today's binding mechanics — a composite-literal field binding is always keyed "TypeName.Field" (never a bare identifier), and compositeLiteralFieldBindings only resolves a field's value through either a direct constructor/factory call or a bare-identifier lookup — never a field-selector expression. Since Go identifiers can't contain ".", a "TypeName.Field" binding can structurally never be discovered via that bare-identifier lookup path, meaning one composite literal currently can never depend on another's binding at all. The fix remains correct, safe, and worth keeping regardless: it removes the order-dependence class of bug outright rather than relying on it happening to not matter today, and it costs at most one extra sweep in the common (no-change) case — verified against weaviate (a real 4500+-file repo), same 4 real usages detected, no measurable performance regression (~2s, unchanged). If composite-literal resolution is ever extended to support selector-expression values (making the theoretical scenario reachable), this fix is already in place for it. Full test suite green, no fixture changes needed since the existing composite-literal fixtures already exercise the (now-looped) pass without any behavior change. Fixes #18 Signed-off-by: Krishan Kant Sharma <krishansharma0327@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe composite-literal field-binding discovery in ChangesComposite-literal binding resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
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.
Summary
Closes #18. Pass B (composite-literal field binding) ran as a single forward sweep over parsed files, not a fixed-point iteration — a theoretical order-dependence risk flagged during independent review of #14, before merge.
Changed to loop until a full sweep discovers nothing new, capped at
len(parsed)+1sweeps as a safety bound a real fixed point can never reach.Honest note on scope
While investigating a regression fixture, I could not construct a reachable repro matching the issue's own illustrative example with today's binding mechanics — a composite-literal field binding is always keyed
"TypeName.Field"(never a bare identifier), andcompositeLiteralFieldBindingsonly resolves a field's value through a direct constructor/factory call or a bare-identifier lookup — never a field-selector expression. Since Go identifiers can't contain., a"TypeName.Field"binding can structurally never be discovered via that bare-identifier lookup path — meaning one composite literal currently can never depend on another's binding at all.The fix is still correct and worth keeping: it removes the order-dependence class of bug outright rather than relying on it happening not to matter today, costs at most one extra sweep in the common (no-change) case, and is already in place if composite-literal resolution is ever extended to support selector-expression values (which would make the scenario reachable).
Verification
Summary by CodeRabbit