Skip to content

Commit

Permalink
go/ssa: sanity check for package transient fields
Browse files Browse the repository at this point in the history
Change-Id: I96badb1a6c4f3737a30e3a5fc5c458a1a64264bf
GitHub-Last-Rev: 9a33283
GitHub-Pull-Request: #519
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613158
Commit-Queue: Alan Donovan <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Tim King <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
  • Loading branch information
xieyuschen authored and adonovan committed Sep 17, 2024
1 parent 2aabc4f commit 0355013
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions go/ssa/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,19 @@ func sanityCheckPackage(pkg *Package) {
if pkg.Pkg == nil {
panic(fmt.Sprintf("Package %s has no Object", pkg))
}
if pkg.info != nil {
panic(fmt.Sprintf("package %s field 'info' is not cleared", pkg))
}
if pkg.files != nil {
panic(fmt.Sprintf("package %s field 'files' is not cleared", pkg))
}
if pkg.created != nil {
panic(fmt.Sprintf("package %s field 'created' is not cleared", pkg))
}
if pkg.initVersion != nil {
panic(fmt.Sprintf("package %s field 'initVersion' is not cleared", pkg))
}

_ = pkg.String() // must not crash

for name, mem := range pkg.Members {
Expand Down

0 comments on commit 0355013

Please sign in to comment.