Implement != operator in expression evaluator

This commit is contained in:
Elara 2023-12-22 15:43:49 -08:00
parent 687e0a6c36
commit 4309bcc3b4

View File

@ -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")