compiler: return error messages with source location

Replace most errors returned by the compiler (using errors.New) with an
error type that includes the source location.
This commit is contained in:
Ayke van Laethem
2018-12-01 17:19:40 +01:00
parent 7bdb606d4f
commit da0a02d128
5 changed files with 86 additions and 69 deletions
+3
View File
@@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
"go/types"
"io"
"io/ioutil"
"os"
@@ -451,6 +452,8 @@ func handleCompilerError(err error) {
fmt.Fprintln(os.Stderr, "unsupported instruction during init evaluation:")
errUnsupported.Inst.Dump()
fmt.Fprintln(os.Stderr)
} else if errCompiler, ok := err.(types.Error); ok {
fmt.Fprintln(os.Stderr, errCompiler)
} else {
fmt.Fprintln(os.Stderr, "error:", err)
}