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 11package expr
22
33import (
4+ "fmt"
45 "reflect"
56
67 "github.com/antonmedv/expr/checker"
@@ -13,6 +14,10 @@ import (
1314
1415// Eval parses, compiles and runs given input.
1516func 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+
1621 tree , err := parser .Parse (input )
1722 if err != nil {
1823 return nil , err
Original file line number Diff line number Diff line change @@ -903,3 +903,9 @@ type segment struct {
903903 Destination string
904904 Date time.Time
905905}
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