@@ -140,15 +140,25 @@ func resolveSymbol(path []string, pkg *cache.Package, pgf *parsego.File) (types.
140
140
switch len (path ) {
141
141
case 1 :
142
142
_ , target := fileScope .LookupParent (path [0 ], token .NoPos )
143
+ if target == nil {
144
+ return nil , fmt .Errorf ("failed to resolve name %q" , path [0 ])
145
+ }
143
146
return target , nil
144
147
case 2 :
145
148
switch _ , obj := fileScope .LookupParent (path [0 ], token .NoPos ); obj := obj .(type ) {
146
149
case * types.PkgName :
147
- return obj .Imported ().Scope ().Lookup (path [1 ]), nil
150
+ target := obj .Imported ().Scope ().Lookup (path [1 ])
151
+ if target == nil {
152
+ return nil , fmt .Errorf ("failed to resolve member %q of %q" , path [1 ], path [0 ])
153
+ }
154
+ return target , nil
148
155
case nil :
149
156
return nil , fmt .Errorf ("failed to resolve name %q" , path [0 ])
150
157
default :
151
158
target , _ , _ := types .LookupFieldOrMethod (obj .Type (), true , pkg .Types (), path [1 ])
159
+ if target == nil {
160
+ return nil , fmt .Errorf ("failed to resolve member %q of %q" , path [1 ], path [0 ])
161
+ }
152
162
return target , nil
153
163
}
154
164
case 3 :
@@ -163,6 +173,9 @@ func resolveSymbol(path []string, pkg *cache.Package, pgf *parsego.File) (types.
163
173
return nil , fmt .Errorf ("invalid qualified symbol: could not find %q in package %q" , path [1 ], path [0 ])
164
174
}
165
175
target , _ , _ := types .LookupFieldOrMethod (recv .Type (), true , pkg .Types (), path [2 ])
176
+ if target == nil {
177
+ return nil , fmt .Errorf ("failed to resolve member %q of %q" , path [2 ], path [1 ])
178
+ }
166
179
return target , nil
167
180
}
168
181
panic ("unreachable" )
0 commit comments