Skip to content

Commit 190e359

Browse files
heathduttonflosch
authored andcommitted
fix(expressions): return actual values from and/or operators instead of booleans
1 parent 794c267 commit 190e359

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

parser_expression.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,23 @@ func (expr *Expression) Evaluate(ctx *ExecutionContext) (*Value, *Error) {
139139
switch expr.opToken.Val {
140140
case "and", "&&":
141141
if !v1.IsTrue() {
142-
return AsValue(false), nil
142+
return v1, nil
143143
} else {
144144
v2, err := expr.expr2.Evaluate(ctx)
145145
if err != nil {
146146
return nil, err
147147
}
148-
return AsValue(v2.IsTrue()), nil
148+
return v2, nil
149149
}
150150
case "or", "||":
151151
if v1.IsTrue() {
152-
return AsValue(true), nil
152+
return v1, nil
153153
} else {
154154
v2, err := expr.expr2.Evaluate(ctx)
155155
if err != nil {
156156
return nil, err
157157
}
158-
return AsValue(v2.IsTrue()), nil
158+
return v2, nil
159159
}
160160
default:
161161
return nil, ctx.Error(fmt.Sprintf("unimplemented: %s", expr.opToken.Val), expr.opToken)

0 commit comments

Comments
 (0)