lang: ast, gapi, interfaces, parser: Print line numbers on error
This adds an initial implementation of printing line numbers on type unification errors. It also attempts to print a visual position indicator for most scenarios. This patch was started by Felix Frank and finished by James Shubin. Co-authored-by: Felix Frank <Felix.Frank.de@gmail.com>
This commit is contained in:
@@ -181,11 +181,19 @@ func TestAstFunc1(t *testing.T) {
|
||||
t.Logf("comment: %s\n", comment)
|
||||
}
|
||||
|
||||
sources := map[string][]byte{}
|
||||
sourceFinder := func(path string) ([]byte, error) {
|
||||
if b, exists := sources[path]; exists {
|
||||
return b, nil
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
// copy files out into the test temp directory
|
||||
var testOutput []byte
|
||||
var testConfig []byte
|
||||
found := false
|
||||
for _, file := range archive.Files {
|
||||
sources["/"+file.Name] = file.Data // store!
|
||||
if file.Name == "OUTPUT" {
|
||||
testOutput = file.Data
|
||||
found = true
|
||||
@@ -247,6 +255,7 @@ func TestAstFunc1(t *testing.T) {
|
||||
if strings.HasPrefix(expstr, magicError) {
|
||||
errStr = strings.TrimPrefix(expstr, magicError)
|
||||
expstr = errStr
|
||||
t.Logf("errStr has length %d", len(errStr))
|
||||
|
||||
if strings.HasPrefix(expstr, magicErrorLexParse) {
|
||||
errStr = strings.TrimPrefix(expstr, magicErrorLexParse)
|
||||
@@ -398,6 +407,7 @@ func TestAstFunc1(t *testing.T) {
|
||||
|
||||
LexParser: parser.LexParse,
|
||||
StrInterpolater: interpolate.StrInterpolate,
|
||||
SourceFinder: sourceFinder,
|
||||
|
||||
Debug: testing.Verbose(), // set via the -test.v flag to `go test`
|
||||
Logf: func(format string, v ...interface{}) {
|
||||
@@ -675,11 +685,19 @@ func TestAstFunc2(t *testing.T) {
|
||||
t.Logf("comment: %s\n", comment)
|
||||
}
|
||||
|
||||
sources := map[string][]byte{}
|
||||
sourceFinder := func(path string) ([]byte, error) {
|
||||
if b, exists := sources[path]; exists {
|
||||
return b, nil
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
// copy files out into the test temp directory
|
||||
var testOutput []byte
|
||||
var testConfig []byte
|
||||
found := false
|
||||
for _, file := range archive.Files {
|
||||
sources["/"+file.Name] = file.Data // store!
|
||||
if file.Name == "OUTPUT" {
|
||||
testOutput = file.Data
|
||||
found = true
|
||||
@@ -939,6 +957,7 @@ func TestAstFunc2(t *testing.T) {
|
||||
|
||||
LexParser: parser.LexParse,
|
||||
StrInterpolater: interpolate.StrInterpolate,
|
||||
SourceFinder: sourceFinder,
|
||||
|
||||
Debug: testing.Verbose(), // set via the -test.v flag to `go test`
|
||||
Logf: func(format string, v ...interface{}) {
|
||||
@@ -1495,11 +1514,19 @@ func TestAstFunc3(t *testing.T) {
|
||||
t.Logf("comment: %s\n", comment)
|
||||
}
|
||||
|
||||
sources := map[string][]byte{}
|
||||
sourceFinder := func(path string) ([]byte, error) {
|
||||
if b, exists := sources[path]; exists {
|
||||
return b, nil
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
// copy files out into the test temp directory
|
||||
var testOutput []byte
|
||||
var testConfig []byte
|
||||
found := false
|
||||
for _, file := range archive.Files {
|
||||
sources["/"+file.Name] = file.Data // store!
|
||||
if file.Name == "OUTPUT" {
|
||||
testOutput = file.Data
|
||||
found = true
|
||||
@@ -1759,6 +1786,7 @@ func TestAstFunc3(t *testing.T) {
|
||||
|
||||
LexParser: parser.LexParse,
|
||||
StrInterpolater: interpolate.StrInterpolate,
|
||||
SourceFinder: sourceFinder,
|
||||
|
||||
Debug: testing.Verbose(), // set via the -test.v flag to `go test`
|
||||
Logf: func(format string, v ...interface{}) {
|
||||
|
||||
Reference in New Issue
Block a user