File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
package expr
2
2
3
3
import (
4
+ "fmt"
4
5
"reflect"
5
6
6
7
"github.com/antonmedv/expr/checker"
@@ -13,6 +14,10 @@ import (
13
14
14
15
// Eval parses, compiles and runs given input.
15
16
func Eval (input string , env interface {}) (interface {}, error ) {
17
+ if _ , ok := env .(conf.Option ); ok {
18
+ return nil , fmt .Errorf ("misused expr.Eval: second argument (env) should be passed without expr.Env" )
19
+ }
20
+
16
21
tree , err := parser .Parse (input )
17
22
if err != nil {
18
23
return nil , err
Original file line number Diff line number Diff line change @@ -903,3 +903,9 @@ type segment struct {
903
903
Destination string
904
904
Date time.Time
905
905
}
906
+
907
+ func TestExpr_eval_with_env (t * testing.T ) {
908
+ _ , err := expr .Eval ("true" , expr .Env (map [string ]interface {}{}))
909
+ assert .Error (t , err )
910
+ assert .Contains (t , err .Error (), "misused" )
911
+ }
You can’t perform that action at this time.
0 commit comments