mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 07:23:39 +00:00
compiler: improve "function redeclared" error
This error can normally only happen with //go:linkname and such, but it's nice to get an informative error message in that case.
This commit is contained in:
committed by
Ron Evans
parent
69c1d802e1
commit
0933577e60
@@ -810,7 +810,12 @@ func (c *Compiler) parseFunc(frame *Frame) {
|
||||
fmt.Printf("\nfunc %s:\n", frame.fn.Function)
|
||||
}
|
||||
if !frame.fn.LLVMFn.IsDeclaration() {
|
||||
c.addError(frame.fn.Pos(), "function is already defined:"+frame.fn.LLVMFn.Name())
|
||||
errValue := frame.fn.LLVMFn.Name() + " redeclared in this program"
|
||||
fnPos := getPosition(frame.fn.LLVMFn)
|
||||
if fnPos.IsValid() {
|
||||
errValue += "\n\tprevious declaration at " + fnPos.String()
|
||||
}
|
||||
c.addError(frame.fn.Pos(), errValue)
|
||||
return
|
||||
}
|
||||
if !frame.fn.IsExported() {
|
||||
|
||||
Reference in New Issue
Block a user