mirror of
https://github.com/golang/go.git
synced 2026-06-28 03:40:37 +00:00
cmd/internal/obj: print error on duplicate symbol definitions
When compiling a package, when there are duplicated symbols (probably due to a bug in the compiler), we try to print the source locations of the two definitions. However, if one has its Func().Text unset, it panics. Guard it with a nil check, so at least it can print the function name. Change-Id: I7a851970edc71dc2c8c9d694174bac42ea9c75d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/775623 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Bypass: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
e49b53439d
commit
55ff407d4f
1 changed files with 5 additions and 1 deletions
|
|
@ -183,7 +183,11 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int, start src.XPos) {
|
|||
return
|
||||
}
|
||||
if s.Func() != nil {
|
||||
ctxt.Diag("%s: symbol %s redeclared\n\t%s: other declaration of symbol %s", ctxt.PosTable.Pos(start), s.Name, ctxt.PosTable.Pos(s.Func().Text.Pos), s.Name)
|
||||
otherPos := src.NoPos
|
||||
if s.Func().Text != nil {
|
||||
otherPos = ctxt.PosTable.Pos(s.Func().Text.Pos)
|
||||
}
|
||||
ctxt.Diag("%s: symbol %s redeclared\n\t%s: other declaration of symbol %s", ctxt.PosTable.Pos(start), s.Name, otherPos, s.Name)
|
||||
return
|
||||
}
|
||||
s.NewFuncInfo()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue