
Most of these errors are actually "todo" or "unimplemented" errors, so the return type is known. This means that compilation can proceed (with errors) even though the output will be incorrect. This is useful because this way, all errors in a compilation unit can be shown together to the user.
18 строки
325 Б
Go
18 строки
325 Б
Go
package compiler
|
|
|
|
import (
|
|
"go/token"
|
|
"go/types"
|
|
)
|
|
|
|
func (c *Compiler) makeError(pos token.Pos, msg string) types.Error {
|
|
return types.Error{
|
|
Fset: c.ir.Program.Fset,
|
|
Pos: pos,
|
|
Msg: msg,
|
|
}
|
|
}
|
|
|
|
func (c *Compiler) addError(pos token.Pos, msg string) {
|
|
c.diagnostics = append(c.diagnostics, c.makeError(pos, msg))
|
|
}
|