Support float in variable range#1356
Conversation
|
Was the behaviour consistent between liquid and liquid-c?
I don't think that is a good thing. If the template author actually wanted a float range, then the silent rounding will be a more subtle bug. If they actually wanted If we do want to support a float range in the future, this coercion would make it harder to add that support, since this change would make it more likely for templates to depend on it. If we want the behaviour to be consistent between static and dynamic ranges, then we should use Liquid::Usage.increment to see if there are dependencies on a float literal being converted to an integer. |
Yes, see eab12e1 (this commit is before the Gemfile was updated to point to the branch on |
Ranges with floats get converted to ranges of integers (e.g.
1.1..5.5gets converted to range1..5) but this is not the case with ranges of variables (e.g. ifx == 1.1andy == 5.5,x..yresults in aLiquid error: invalid integer). This is because floats are not handled inRangeLookup#to_integerso it delegates toUtils.to_integer(input), which first converts the float to a string and then tries to convert it back to an integer.