@@ -107,8 +107,14 @@ func (p *GoParser) parseVar(ctx *fileContext, vspec *ast.ValueSpec, isConst bool
107107 // igore anonymous var
108108 continue
109109 }
110- if vspec .Values != nil {
111- val = & vspec .Values [i ]
110+ val = nil
111+ if len (vspec .Values ) > 0 {
112+ // In this case: _, b, _, _ = runtime.Caller(0), vspec.Values only has one element
113+ if len (vspec .Values ) == 1 && i > 0 {
114+ val = & vspec .Values [0 ]
115+ } else if i < len (vspec .Values ) {
116+ val = & vspec .Values [i ]
117+ }
112118 }
113119 v = p .newVar (ctx .module .Name , ctx .pkgPath , name .Name , isConst )
114120 v .FileLine = ctx .FileLine (vspec )
@@ -141,6 +147,29 @@ func (p *GoParser) parseVar(ctx *fileContext, vspec *ast.ValueSpec, isConst bool
141147 v .Dependencies = InsertDependency (v .Dependencies , NewDependency (dep , ctx .FileLine (vspec .Type )))
142148 }
143149 } else if val != nil {
150+ // Handle function call returning multiple values. For example: _, b, _, _ = runtime.Caller(0)
151+ // If no these logic, the type of b is (pc uintptr, file string, line int, ok bool)
152+ if _ , ok := (* val ).(* ast.CallExpr ); ok {
153+ // Get function signature type
154+ if tinfo , ok := ctx .pkgTypeInfo .Types [* val ]; ok {
155+ if results , ok := tinfo .Type .(* types.Tuple ); ok {
156+ // Ensure index is valid
157+ if i < results .Len () {
158+ // Get the specific result type for this index
159+ resultType := results .At (i ).Type ()
160+ // Get type info for this specific result type
161+ ti := ctx .getTypeinfo (resultType )
162+ v .Type = & ti .Id
163+ v .IsPointer = ti .IsPointer
164+ for _ , dep := range ti .Deps {
165+ v .Dependencies = InsertDependency (v .Dependencies , NewDependency (dep , ctx .FileLine (* val )))
166+ }
167+ continue
168+ }
169+ }
170+ }
171+ }
172+ // Fallback to original behavior if not a function call or index invalid
144173 ti := ctx .GetTypeInfo (* val )
145174 v .Type = & ti .Id
146175 v .IsPointer = ti .IsPointer
0 commit comments