Refactor VM and operators
This commit is contained in:
20
internal/object/errors.go
Normal file
20
internal/object/errors.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package object
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BinaryOpError is an binary operation error usually resulting from mismatched types
|
||||
type BinaryOpError struct {
|
||||
left, right Object
|
||||
op string
|
||||
}
|
||||
|
||||
func (e BinaryOpError) Error() string {
|
||||
return fmt.Sprintf("unsupported types for binary operation: %s %s %s", e.left.Type(), e.op, e.right.Type())
|
||||
}
|
||||
|
||||
// NewBinaryOpError returns a new BinaryOpError
|
||||
func NewBinaryOpError(left, right Object, op string) BinaryOpError {
|
||||
return BinaryOpError{left, right, op}
|
||||
}
|
||||
Reference in New Issue
Block a user