Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why interface{} value is considered as time.Time in binary minus operation #401

Closed Unanswered
IgorKalet asked this question in General
Discussion options

Compilation of quite simple expression raises the following error:

invalid operation: / (mismatched types time.Time and interface {}) (1:13)
 | (a - b + c) / d
 | ............^

It happens because the binary minus processing has the following check:
https://github.com/antonmedv/expr/blob/2eb6a03aacf9ca8a87685a6f3b1adc3e8473b295/checker/checker.go#L262
And function isTime ends with the following:
https://github.com/antonmedv/expr/blob/2eb6a03aacf9ca8a87685a6f3b1adc3e8473b295/checker/types.go#L101

Changing of return isAny(t) to return false solves this problem.

BTW Compilation of (a + -b + c) / d and (a + c - b) / d expressions are ok w/o above change.

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

Please, provide full example.

You must be logged in to vote
1 reply
Comment options

Here you are
main.txt

Comment options

Yes, looks like a problem with isTime() function.

Fixed and added regression test in 23efe7b

Thanks for reporting.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /