@@ -727,7 +727,8 @@ func extractScopeLocation(tw *trap.Writer, scope *types.Scope, lbl trap.Label) {
727
727
}
728
728
729
729
// extractScopes extracts symbol table information for the package scope and all local scopes
730
- // of the given package
730
+ // of the given package. Note that this will not encounter methods or struct fields as
731
+ // they do not have a parent scope.
731
732
func extractScopes (tw * trap.Writer , nd * ast.File , pkg * packages.Package ) {
732
733
pkgScopeLabel := extractPackageScope (tw , pkg )
733
734
fileScope := pkg .TypesInfo .Scopes [nd ]
@@ -1457,7 +1458,9 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
1457
1458
for i := 0 ; i < tp .NumFields (); i ++ {
1458
1459
field := tp .Field (i )
1459
1460
1460
- // ensure the field is associated with a label
1461
+ // ensure the field is associated with a label - note that
1462
+ // struct fields do not have a parent scope, so they are not
1463
+ // dealt with by `extractScopes`
1461
1464
fieldlbl , exists := tw .Labeler .FieldID (field , i , lbl )
1462
1465
if ! exists {
1463
1466
extractObject (tw , field , fieldlbl )
@@ -1479,6 +1482,8 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
1479
1482
for i := 0 ; i < tp .NumMethods (); i ++ {
1480
1483
meth := tp .Method (i )
1481
1484
1485
+ // Note that methods do not have a parent scope, so they are
1486
+ // not dealt with by `extractScopes`
1482
1487
extractMethod (tw , meth )
1483
1488
1484
1489
extractComponentType (tw , lbl , i , meth .Name (), meth .Type ())
@@ -1537,7 +1542,8 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
1537
1542
dbscheme .TypeObjectTable .Emit (tw , lbl , entitylbl )
1538
1543
}
1539
1544
1540
- // ensure all methods have labels
1545
+ // ensure all methods have labels - note that methods do not have a
1546
+ // parent scope, so they are not dealt with by `extractScopes`
1541
1547
for i := 0 ; i < origintp .NumMethods (); i ++ {
1542
1548
meth := origintp .Method (i )
1543
1549
0 commit comments