Skip to content

Commit 23efe7b

Browse files
committed
Fix isTime() func
1 parent 5724806 commit 23efe7b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

checker/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func isTime(t reflect.Type) bool {
9898
return true
9999
}
100100
}
101-
return isAny(t)
101+
return false
102102
}
103103

104104
func isDuration(t reflect.Type) bool {

expr_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,3 +1791,17 @@ func TestEnv_keyword(t *testing.T) {
17911791
}
17921792

17931793
}
1794+
1795+
func TestIssue401(t *testing.T) {
1796+
program, err := expr.Compile("(a - b + c) / d", expr.AllowUndefinedVariables())
1797+
require.NoError(t, err, "compile error")
1798+
1799+
output, err := expr.Run(program, map[string]interface{}{
1800+
"a": 1,
1801+
"b": 2,
1802+
"c": 3,
1803+
"d": 4,
1804+
})
1805+
require.NoError(t, err, "run error")
1806+
require.Equal(t, 0.5, output)
1807+
}

0 commit comments

Comments
 (0)