pkg/eval: Remove the bool return value of GetCompilationError.

This is done for consistency with parse.GetError.
This commit is contained in:
Qi Xiao 2021-01-01 23:26:24 +00:00
parent 7584319b69
commit 5f0e4fc196
2 changed files with 6 additions and 6 deletions

View File

@ -10,11 +10,11 @@ func NewCompilationError(message string, context diag.Context) error {
Type: compilationErrorType, Message: message, Context: context} Type: compilationErrorType, Message: message, Context: context}
} }
// GetCompilationError returns a *diag.Error and true if the given value is a // GetCompilationError returns a *diag.Error if the given value is a compilation
// compilation error. Otherwise it returns nil and false. // error. Otherwise it returns nil.
func GetCompilationError(e interface{}) (*diag.Error, bool) { func GetCompilationError(e interface{}) *diag.Error {
if e, ok := e.(*diag.Error); ok && e.Type == compilationErrorType { if e, ok := e.(*diag.Error); ok && e.Type == compilationErrorType {
return e, true return e
} }
return nil, false return nil
} }

View File

@ -54,7 +54,7 @@ func compile(b, g *staticNs, tree parse.Tree, w io.Writer) (op Op, err error) {
r := recover() r := recover()
if r == nil { if r == nil {
return return
} else if e, ok := GetCompilationError(r); ok { } else if e := GetCompilationError(r); e != nil {
// Save the compilation error and stop the panic. // Save the compilation error and stop the panic.
err = e err = e
} else { } else {