Closed
Description
Invoking PathEnclosingInterval on the extent of x
in this program:
package p
func f(x int)
gives this result:
Path enclosing interval #18-19 [exact=true]:
[0] *ast.Ident @ 3:8-3:9 (#18-19)
[1] *ast.Field @ 3:8-3:13 (#18-23)
[2] *ast.FieldList @ 3:7-3:14 (#17-24)
[3] *ast.FuncDecl @ 3:1-3:14 (#11-24) Type.Scope={x}
[4] *ast.File @ 1:1-3:14 (#0-24) Scope={}
The FuncType--FuncDecl.Type, which holds the Params FieldList--is nowhere to be seen.
I'm sure this is because the invariant that each node contains its children has an edge case for FuncType: the FuncDecl for func f(x int)
has a FuncType that includes the func
token and the (x int)
signature but not the name f
(FuncDecl.Name), or the receiver for a method.
I'm amazed we haven't noticed this before.