fix(registry): restrict same-module suffix resolution to self/namespace receivers#893
Open
sahil-mangla wants to merge 4 commits into
Open
fix(registry): restrict same-module suffix resolution to self/namespace receivers#893sahil-mangla wants to merge 4 commits into
sahil-mangla wants to merge 4 commits into
Conversation
Owner
|
Thanks for the focused #876 fix. Triage: parsing/quality bug, normal priority. Review should verify the receiver restriction removes store/delegation false positives without regressing legitimate same-module self or namespace receiver calls. The small registry-focused diff is a good shape for this bug. |
… receivers Limit same-module suffix fallback in resolve_same_module to only fire if the receiver is a self-receiver or matches the module/namespace. Also reject matching dotted/colon-qualified callees targeting a Function to a different prefix in name lookup. This prevents false-positive recursion flags on store/delegation calls. Signed-off-by: sahil-mangla <manglasahil2017@gmail.com>
Signed-off-by: sahil-mangla <manglasahil2017@gmail.com>
Java enums with methods (e.g. isWeekend/label in cp_enum_method_java) have their method declarations inside enum_body_declarations, which is a child of enum_body — not a direct child of enum_body itself. find_class_body was returning the raw enum_body node (16 children: enum_constant×7, commas, and the nested enum_body_declarations). As a result, extract_class_methods iterated enum_constant/comma nodes and never visited any method_declaration, so no Method nodes were created and no CALLS edges resolved. Fixes: - find_class_body: if a body resolved via field-name lookup is enum_body, look for enum_body_declarations inside it and return that instead. - find_class_body fallback loop: same unwrapping for the type-scan path. - push_class_body_children: add enum_body and enum_body_declarations to the recognised body-container kinds so the walk_defs stack correctly scopes enum method children under the enum QN. Tests: convergence_probe 47/47 passed (was 46/47, cp_enum_method_java was the failing case). Signed-off-by: sahil-mangla <manglasahil2017@gmail.com>
Wrap two if-conditions that exceeded the 100-column limit: - Line 3506: break &&-condition before the parenthesised ObjC/Java language check so the line stays within 100 cols. - Lines 5860-5861: split the combined enum_body / enum_body_declarations comparison onto separate continuation lines to satisfy the limit. No logic change; formatting only. Signed-off-by: sahil-mangla <manglasahil2017@gmail.com>
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.
What does this PR do?
This PR fixes #876 false-positive recursion flags (
unguarded_recursion,self_recursive,recursive) occurring on store wrappers, singleton delegations, and other method calls targeting unrelated objects that happen to share a name with a top-level function in the current module (e.g._get_store().get(...)insideget(...)or_default.check(...)insidecheck(...)).Root Cause
During call graph resolution in Strategy 2 (
resolve_same_moduleinsrc/pipeline/registry.c), dotted/colon-separated callee names (like_default.check) were split intoprefix(_default) andsuffix(check). The resolver fell back to checking if the suffix exists as a top-level function in the caller's module (module_qn.check). If a localcheckfunction was defined, it matched and mistakenly resolved the call to it, generating a self-loopCALLSedge which flagged the function as recursive.Solution
is_same_module_receiverto validate the receiver prefix. Suffix fallback checks inresolve_same_moduleare now restricted to:"self","this","cls","@self"..<prefix>).axios.get,_get_store().get,_default.check) from matching same-module top-level functions, eliminating spuriousCALLSself-loops.tests/test_registry.c(resolve_same_module_only_on_self_receiver) to cover delegation, self, and namespace/module receiver pattern cases.Checklist
git commit -s) — required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)