go/ssa: reenable TestStdlib

It wasn't broken on the builder--only with my local go toolchain.
(There was some cgo-related problem with cmd/cgo/internal/test.)
At least that explains why we didn't notice the failures...

This CL also adds a missing error check that made the real cause
of the problem hard to spot, and improves some comments and
assertions.

Fixes golang/go#69287

Change-Id: Iccbe2a72770499749ca780f78e2a61d5576f613b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612044
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/go/ssa/stdlib_test.go b/go/ssa/stdlib_test.go
index e56d6a9..391240a 100644
--- a/go/ssa/stdlib_test.go
+++ b/go/ssa/stdlib_test.go
@@ -35,13 +35,18 @@
 	return stats.Alloc
 }
 
-// TestStdlib loads the entire standard library and its tools.
+// TestStdlib loads the entire standard library and its tools and all
+// their dependencies.
+//
+// (As of go1.23, std is transitively closed, so adding the -deps flag
+// doesn't increase its result set. The cmd pseudomodule of course
+// depends on a good chunk of std, but the std+cmd set is also
+// transitively closed, so long as -pgo=off.)
 //
 // Apart from a small number of internal packages that are not
 // returned by the 'std' query, the set is essentially transitively
 // closed, so marginal per-dependency costs are invisible.
 func TestStdlib(t *testing.T) {
-	t.Skip("broken; see https://go.dev/issues/69287")
 	testLoad(t, 500, "std", "cmd")
 }
 
@@ -78,6 +83,9 @@
 	if err != nil {
 		t.Fatal(err)
 	}
+	if packages.PrintErrors(pkgs) > 0 {
+		t.Fatal("there were errors loading the packages")
+	}
 
 	t1 := time.Now()
 	alloc1 := bytesAllocated()
@@ -195,9 +203,13 @@
 				if decl, ok := decl.(*ast.FuncDecl); ok {
 					obj := pkg.TypesInfo.Defs[decl.Name].(*types.Func)
 					if obj == nil {
-						panic("nil *Func")
+						panic("nil *types.Func: " + decl.Name.Name)
 					}
-					addSrcFunc(prog.FuncValue(obj))
+					fn := prog.FuncValue(obj)
+					if fn == nil {
+						panic("nil *ssa.Function: " + obj.String())
+					}
+					addSrcFunc(fn)
 				}
 			}
 		}