EvalBool evaluates e with this and returns the result if it is a bool or error. Otherwise, EvalBool returns an error.
(sctx *super.Context, this super.Value, e Evaluator)
| 64 | // EvalBool evaluates e with this and returns the result if it is a bool or error. |
| 65 | // Otherwise, EvalBool returns an error. |
| 66 | func EvalBool(sctx *super.Context, this super.Value, e Evaluator) super.Value { |
| 67 | val := e.Eval(this) |
| 68 | if super.TypeUnder(val.Type()) == super.TypeBool || val.IsNull() || val.IsError() { |
| 69 | return val |
| 70 | } |
| 71 | return sctx.WrapError("not type bool", val) |
| 72 | } |
| 73 | |
| 74 | func (a *And) Eval(this super.Value) super.Value { |
| 75 | lhs := EvalBool(a.sctx, this, a.lhs) |