feat(go): Resolve stdlib return types in variable extraction (PR-07)#554
Merged
shivasurya merged 1 commit intomainfrom Feb 25, 2026
Merged
feat(go): Resolve stdlib return types in variable extraction (PR-07)#554shivasurya merged 1 commit intomainfrom
shivasurya merged 1 commit intomainfrom
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #554 +/- ##
==========================================
+ Coverage 83.25% 83.32% +0.06%
==========================================
Files 143 143
Lines 17710 17746 +36
==========================================
+ Hits 14744 14786 +42
+ Misses 2426 2423 -3
+ Partials 540 537 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Feb 25, 2026
Owner
Author
This was referenced Feb 25, 2026
Owner
Author
Merge activity
|
…R-25)
Extends the Go variable extraction pass (Pass 2b) to resolve return types
of stdlib function calls using the StdlibLoader attached to the module
registry.
Previously, variables assigned from stdlib calls (e.g., `resp := http.Get(url)`)
remained untyped because the TypeInferenceEngine only covers project-defined
functions. Now, when the engine has no entry for a call, the extraction pass
consults the StdlibLoader as a fallback.
Changes:
- inferTypeFromFunctionCall: falls back to inferTypeFromStdlibFunction
after a TypeInferenceEngine miss
- inferTypeFromStdlibFunction: new helper — validates the import path is
stdlib, calls StdlibLoader.GetFunction, picks the first non-error return
- normalizeStdlibReturnType: new helper — converts raw JSON type strings
("*Request", "string", "io.Reader") to TypeFQNs ("net/http.Request",
"builtin.string", "io.Reader")
- go_variables_stdlib_test.go: 21 new tests covering both helpers and
three integration scenarios via ExtractGoVariableAssignments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
85b7a94 to
14ce58c
Compare
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
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
StdlibLoaderattached to the module registryresp := http.Get(url)) remained untyped; now they receive a concrete TypeFQN (e.g.,net/http.Response)inferTypeFromStdlibFunctionhelper that validates the import path is stdlib, callsStdlibLoader.GetFunction, and picks the first non-error returnnormalizeStdlibReturnTypehelper that converts raw JSON type strings ("*Request","string","io.Reader") to TypeFQNs ("net/http.Request","builtin.string","io.Reader")StdlibLoaderis nil (network unavailable), variables remain untyped and no error is raisedgo_variables_stdlib_test.gocovering both helpers (unit) and three end-to-endExtractGoVariableAssignmentsscenariosTest plan
go test ./graph/callgraph/extraction/... -v -run "TestNormalize|TestInferTypeFromStdlib|TestExtractGoVariables_Stdlib"— all 21 passgo test ./...— all 29 packages passgolangci-lint run ./graph/callgraph/extraction/...— 0 issuesnormalizeStdlibReturnType— 100% coverage;inferTypeFromStdlibFunction— 93.3%🤖 Generated with Claude Code