Added more tests

This commit is contained in:
2024-06-22 13:20:11 +02:00
parent 4faa1641c6
commit 2f7319e6a0
6 changed files with 84 additions and 22 deletions

View File

@ -2,5 +2,7 @@ package errors
var (
InvalidStatement = &Base{"Invalid statement"}
InvalidExpression = &Base{"Invalid expression"}
MissingAssignValue = &Base{"Missing assignment value"}
NotImplemented = &Base{"Not implemented"}
)

View File

@ -0,0 +1,18 @@
package errors
import "fmt"
// UnknownIdentifier represents unknown variables.
type UnknownIdentifier struct {
Name string
CorrectName string
}
// Error generates the string representation.
func (err *UnknownIdentifier) Error() string {
if err.CorrectName != "" {
return fmt.Sprintf("Unknown variable '%s', did you mean '%s'?", err.Name, err.CorrectName)
}
return fmt.Sprintf("Unknown variable '%s'", err.Name)
}