mirror of
https://github.com/golang/go
synced 2024-11-05 11:46:12 -07:00
go/internal/gcimporter: handle the possibility of a nil fileset
This panic was found by running the gopherjs tests: https://circleci.com/gh/gopherjs/gopherjs/1767. Change-Id: Ica97f31d20bbbd541b40ae3fd17594238883706a Reviewed-on: https://go-review.googlesource.com/c/tools/+/198857 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
88641d98b3
commit
72853e10c5
@ -267,6 +267,11 @@ func (w *exportWriter) tag(tag byte) {
|
||||
}
|
||||
|
||||
func (w *exportWriter) pos(pos token.Pos) {
|
||||
if w.p.fset == nil {
|
||||
w.int64(0)
|
||||
return
|
||||
}
|
||||
|
||||
p := w.p.fset.Position(pos)
|
||||
file := p.Filename
|
||||
line := int64(p.Line)
|
||||
|
@ -198,7 +198,8 @@ func TestIExportData_typealiases(t *testing.T) {
|
||||
checkPkg(t, pkg1, "export")
|
||||
|
||||
// export
|
||||
exportdata, err := gcimporter.IExportData(fset1, pkg1)
|
||||
// use a nil fileset here to confirm that it doesn't panic
|
||||
exportdata, err := gcimporter.IExportData(nil, pkg1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user