From 8433412b741e60f8a6f9608bcf81a6ce1a10a75e Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 8 Apr 2025 14:12:00 -0400 Subject: [PATCH] go/types: document that Defs[id] may be missing in ill-typed code Updates #70968 Change-Id: Id0a4acd6bad917ba8a5c439625bca14469b6eb7c Reviewed-on: https://go-review.googlesource.com/c/go/+/663895 Auto-Submit: Alan Donovan LUCI-TryBot-Result: Go LUCI Commit-Queue: Alan Donovan Reviewed-by: Robert Findley --- src/go/types/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/go/types/api.go b/src/go/types/api.go index beb2258c8b..f60c2ff7ee 100644 --- a/src/go/types/api.go +++ b/src/go/types/api.go @@ -254,6 +254,9 @@ type Info struct { // // For an embedded field, Defs returns the field *Var it defines. // + // In ill-typed code, such as a duplicate declaration of the + // same name, Defs may lack an entry for a declaring identifier. + // // Invariant: Defs[id] == nil || Defs[id].Pos() == id.Pos() Defs map[*ast.Ident]Object