Implement != operator in expression evaluator
This commit is contained in:
parent
687e0a6c36
commit
4309bcc3b4
2
expr.go
2
expr.go
@ -63,6 +63,8 @@ func (t *Template) performOp(a, b reflect.Value, op ast.Operator) (any, error) {
|
|||||||
switch op.Value {
|
switch op.Value {
|
||||||
case "==":
|
case "==":
|
||||||
return a.Equal(b), nil
|
return a.Equal(b), nil
|
||||||
|
case "!=":
|
||||||
|
return !a.Equal(b), nil
|
||||||
case "&&":
|
case "&&":
|
||||||
if a.Kind() != reflect.Bool || b.Kind() != reflect.Bool {
|
if a.Kind() != reflect.Bool || b.Kind() != reflect.Bool {
|
||||||
return nil, ast.PosError(op, "logical operations may only be performed on boolean values")
|
return nil, ast.PosError(op, "logical operations may only be performed on boolean values")
|
||||||
|
Loading…
Reference in New Issue
Block a user