Skip to content

Commit ed5a15c

Browse files
rscgopherbot
authored andcommitted
go/internal/gcimporter: replace assert with more helpful panic
If this code is misused, the result of the assert is panic: assertion failed This CL replaces the panic text with a useful message. Change-Id: I3710ebe975e7f1e907b0378e9c67dd0c224492fb Reviewed-on: https://go-review.googlesource.com/c/tools/+/310513 Trust: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Austin Clements <[email protected]> Auto-Submit: Russ Cox <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent f4515dd commit ed5a15c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

go/internal/gcimporter/iexport.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ func (p *iexporter) stringOff(s string) uint64 {
251251
// pushDecl adds n to the declaration work queue, if not already present.
252252
func (p *iexporter) pushDecl(obj types.Object) {
253253
// Package unsafe is known to the compiler and predeclared.
254-
assert(obj.Pkg() != types.Unsafe)
254+
// Caller should not ask us to do export it.
255+
if obj.Pkg() == types.Unsafe {
256+
panic("cannot export package unsafe")
257+
}
255258

256259
if _, ok := p.declIndex[obj]; ok {
257260
return

0 commit comments

Comments
 (0)