Skip to content

feat(go): Close stdlib type inference gap in GetReturnType (PR-07b)#555

Merged
shivasurya merged 1 commit intomainfrom
shiva/go-stdlib-support-pr07b
Feb 25, 2026
Merged

feat(go): Close stdlib type inference gap in GetReturnType (PR-07b)#555
shivasurya merged 1 commit intomainfrom
shiva/go-stdlib-support-pr07b

Conversation

@shivasurya
Copy link
Owner

Summary

  • Enhance GoTypeInferenceEngine.GetReturnType in resolution/go_types.go to fall back to the stdlib registry when the local user-code type map has no answer
  • All code paths that call GetReturnType (type chaining, bidirectional inference, variable extraction) now receive stdlib type data automatically without any per-caller changes
  • Add stdlibNormalizeType helper with the same pointer/slice/builtin/cross-package normalization logic as the extraction layer
  • Fix extraction integration test: type now resolves via the engine (Source: "stdlib", Confidence: 1.0) instead of the extraction-layer fallback

Gap closed

Previously GoTypeInferenceEngine.GetReturnType only looked up user-code types. Any code path that called it for a stdlib function got (nil, false) even when StdlibLoader was set. The extraction-layer helper in go_variables.go worked around this for variable assignments, but chaining and bidirectional inference paths were still blind to stdlib types.

Test coverage

  • go_types.go: 100% coverage on every function (15/15)
  • stdlibNormalizeType: all branches covered (builtin, pointer, slice, cross-package, unqualified, empty)
  • GetReturnType stdlib fallback: 10 new focused tests (nil loader, no dot, not stdlib, fn not found, error-only return, empty-typeFQN skip, local priority, pointer return, cross-package, simple function)
  • Full test suite: all 30 packages green, 0 lint issues

Files changed

File Change
resolution/go_types.go Add stdlib fallback in GetReturnType + stdlibNormalizeType helper
resolution/go_types_test.go Add mockGoTypesStdlibLoader, 10+ new tests covering all new branches
extraction/go_variables_stdlib_test.go Update source assertion from stdlib_registrystdlib

@shivasurya shivasurya added enhancement New feature or request go Pull requests that update go code labels Feb 25, 2026
@shivasurya shivasurya self-assigned this Feb 25, 2026
@shivasurya shivasurya added enhancement New feature or request go Pull requests that update go code labels Feb 25, 2026
@safedep
Copy link

safedep bot commented Feb 25, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.34%. Comparing base (806a944) to head (0b2c209).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
+ Coverage   83.30%   83.34%   +0.03%     
==========================================
  Files         143      143              
  Lines       17746    17782      +36     
==========================================
+ Hits        14784    14820      +36     
  Misses       2424     2424              
  Partials      538      538              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner Author

shivasurya commented Feb 25, 2026

Merge activity

  • Feb 25, 3:17 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 25, 3:32 AM UTC: Graphite couldn't merge this PR because it had merge conflicts.
  • Feb 25, 3:54 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 25, 3:54 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from shiva/go-stdlib-support-pr07 to graphite-base/555 February 25, 2026 03:28
@shivasurya shivasurya changed the base branch from graphite-base/555 to main February 25, 2026 03:30
…-07b)

Enhance GoTypeInferenceEngine.GetReturnType to query the stdlib registry
when local user-code types are not found. All code paths that call
GetReturnType (chaining, bidirectional inference, variable extraction) now
benefit from stdlib type resolution automatically.

- Add stdlib fallback to GetReturnType using Registry.StdlibLoader
- Add stdlibNormalizeType helper (pointer/slice/builtin/qualified handling)
- 100% coverage on every function in go_types.go (15/15 functions)
- Fix extraction test: stdlib type now resolved via engine (Source: stdlib)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shivasurya shivasurya force-pushed the shiva/go-stdlib-support-pr07b branch from cb724bb to 0b2c209 Compare February 25, 2026 03:51
@github-actions
Copy link

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 3
Rules 38

Powered by Code Pathfinder

@shivasurya shivasurya merged commit 8a0e79b into main Feb 25, 2026
7 checks passed
@shivasurya shivasurya deleted the shiva/go-stdlib-support-pr07b branch February 25, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant