Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod and modBool should accept output of other math functions #575

Closed
stou opened this issue Oct 21, 2014 · 3 comments
Closed

mod and modBool should accept output of other math functions #575

stou opened this issue Oct 21, 2014 · 3 comments
Labels

Comments

@stou
Copy link
Contributor

stou commented Oct 21, 2014

I am trying to use the math functions in a template like this:

{{ $hmm := modBool (add 1 3) 2}}

Which gives me an error

 ERROR: 2014/10/21 Error while rendering homepage: template: theme/index.html:7:28: executing         "theme/index.html" at <3>: wrong type for value; expected int; got int64

I guess it is some problem with the doArithmetic() in template.go
Not sure how to solve it though.

@stou
Copy link
Contributor Author

stou commented Oct 21, 2014

Also doing something like (i know I should not try to divide by zero):

{{ $hmm := mod 4 0 }}

causes the application to crash:

panic: runtime error: integer divide by zero [recovered]

Maybe the modulo should also be handled by the doArithmetic() function to allow better error handling and type conversions

@tatsushid
Copy link
Contributor

Those are caused by the type mismatch. doArithmetic returns int64 after calculation but mod and modBool expect int as those argument. I think both of them should receive any int family types

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants