gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.02k stars 7.54k forks source link

Preserve input type in math functions #13041

Closed KN4CK3R closed 1 week ago

KN4CK3R commented 1 week ago

The docs of add tell us

If one of the numbers is a float, the result is a float.

which is not true if two zeros are added because internally != 0 is used as implicit type check. So add (0 | float) (0 | float) returns an int zero.

This PR remembers the input types and uses the correct type for the return value.

CLAassistant commented 1 week ago

CLA assistant check
All committers have signed the CLA.