@@ -65,7 +65,7 @@ func (n unaryNode) Eval(env interface{}) (interface{}, error) {
6565
6666 switch n .operator {
6767 case "not" , "!" :
68- return ! toBool ( n , val ), nil
68+ return ! val .( bool ), nil
6969 }
7070
7171 v := toNumber (n , val )
@@ -87,22 +87,22 @@ func (n binaryNode) Eval(env interface{}) (interface{}, error) {
8787
8888 switch n .operator {
8989 case "or" , "||" :
90- if toBool ( n . left , left ) {
90+ if left .( bool ) {
9191 return true , nil
9292 }
9393 right , err := n .right .Eval (env )
9494 if err != nil {
9595 return nil , err
9696 }
97- return toBool ( n . right , right ), nil
97+ return right .( bool ), nil
9898
9999 case "and" , "&&" :
100- if toBool ( n . left , left ) {
100+ if left .( bool ) {
101101 right , err := n .right .Eval (env )
102102 if err != nil {
103103 return nil , err
104104 }
105- return toBool ( n . right , right ), nil
105+ return right .( bool ), nil
106106 }
107107 return false , nil
108108 }
@@ -134,7 +134,7 @@ func (n binaryNode) Eval(env interface{}) (interface{}, error) {
134134 return ! ok , nil
135135
136136 case "~" :
137- return toText ( n . left , left ) + toText ( n . right , right ), nil
137+ return left .( string ) + right .( string ), nil
138138 }
139139
140140 // Next goes operators on numbers
@@ -216,15 +216,15 @@ func (n matchesNode) Eval(env interface{}) (interface{}, error) {
216216 }
217217
218218 if n .r != nil {
219- return n .r .MatchString (toText ( n . left , left )), nil
219+ return n .r .MatchString (left .( string )), nil
220220 }
221221
222222 right , err := n .right .Eval (env )
223223 if err != nil {
224224 return nil , err
225225 }
226226
227- matched , err := regexp .MatchString (toText ( n . right , right ), toText ( n . left , left ))
227+ matched , err := regexp .MatchString (right .( string ), left .( string ))
228228 if err != nil {
229229 return nil , err
230230 }
@@ -361,7 +361,7 @@ func (n conditionalNode) Eval(env interface{}) (interface{}, error) {
361361 }
362362
363363 // If
364- if toBool ( n . cond , cond ) {
364+ if cond .( bool ) {
365365 // Then
366366 a , err := n .exp1 .Eval (env )
367367 if err != nil {
0 commit comments