feat(go): eager scope creation + parameter-aware RHS inference#642
Open
shivasurya wants to merge 2 commits intoshiva/pr-01-golang-thirdpartyfrom
Open
feat(go): eager scope creation + parameter-aware RHS inference#642shivasurya wants to merge 2 commits intoshiva/pr-01-golang-thirdpartyfrom
shivasurya wants to merge 2 commits intoshiva/pr-01-golang-thirdpartyfrom
Conversation
Fix B.1: indexGoFunctions now accepts a GoTypeInferenceEngine and creates an empty GoFunctionScope for every indexed Go function during Pass 1. This ensures Pattern 1b Source 2 always finds a scope even when all variable inferences in Pass 2b fail (e.g., functions with only parameter-based method calls). Fix B.2: inferTypeFromRHS gains a parameter-aware fallback via the new inferTypeFromParamMethodCall helper. When obj.Method() is encountered and obj matches a function parameter, the method's return type is resolved through StdlibLoader → ThirdPartyLoader (Check 2/2.5 order). Thread callGraph through ExtractGoVariableAssignments and the 5 functions in its call chain to enable the param lookup. Duplicates splitGoTypeFQN / resolveGoTypeFQN in the extraction package to avoid an import cycle between extraction and builder. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## shiva/pr-01-golang-thirdparty #642 +/- ##
==============================================================
Coverage 84.21% 84.22%
==============================================================
Files 162 162
Lines 23256 23327 +71
==============================================================
+ Hits 19586 19648 +62
- Misses 2936 2940 +4
- Partials 734 739 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add targeted tests for uncovered branches in inferTypeFromParamMethodCall: - Package alias receiver (already handled by inferTypeFromFunctionCall) - Method not found in type's method set - Error-only return values (no usable non-error type) - Unqualified parameter type (no dot → extractionSplitGoTypeFQN returns false) Coverage for inferTypeFromParamMethodCall: 83.3% → 90.5%. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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
indexGoFunctionsnow accepts aGoTypeInferenceEngineand eagerly creates an emptyGoFunctionScopefor every indexed Go function during Pass 1. Eliminates[debug-1b] no scope forlog messages for functions where all Pass 2b variable inferences fail.inferTypeFromParamMethodCallhelper resolves method return types when the receiver matches a function parameter (e.g.r.FormValue("id")→builtin.stringvianet/http.Request). ThreadscallGraphthroughExtractGoVariableAssignmentsand its 5-function call chain.splitGoTypeFQN/resolveGoTypeFQNin theextractionpackage to avoid an import cycle withbuilder.Test plan
TestIndexGoFunctions_EagerScopeCreation— scope exists for every indexed functionTestIndexGoFunctions_EagerScope_NilTypeEngine— no panic with nil engineTestIndexGoFunctions_EagerScope_NotOverwritten— pre-existing Pass 2b bindings preservedTestParamAwareRHSInference_StdlibParam—r.FormValue("id")→builtin.stringvia StdlibLoaderTestParamAwareRHSInference_ThirdPartyParam—c.Query("search")→builtin.stringvia ThirdPartyLoaderTestParamAwareRHSInference_NilCallGraph— graceful no-op with nil callGraphTestParamAwareRHSInference_UnknownParam— no binding for non-parameter receivergo test ./...— 29/29 packages passgolangci-lint run— 0 issues🤖 Generated with Claude Code