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

Weird range handling #1604

Closed
charlespwd opened this issue Aug 11, 2022 · 1 comment · Fixed by #1607
Closed

Weird range handling #1604

charlespwd opened this issue Aug 11, 2022 · 1 comment · Fixed by #1607

Comments

@charlespwd
Copy link
Contributor

charlespwd commented Aug 11, 2022

Template.parse("{{ (true..false) }}") throws a NoMethodError .to_i on TrueClass.

I had a partial fix in 185ad2e, but it looks like that's breaking lax parse with an extra dot by throwing an Liquid::ArgumentError instead of rendering.

Don't really have more time to put on this right now so I'm opening an issue instead :D

@dylanahsmith
Copy link
Contributor

Seems like we can just rescue a NoMethodError from start_obj.to_i..end_obj.to_i and turn it into a Liquid::SyntaxError with an appropriate message. There is no need to tolerate this, since it already wasn't working and the liquid code is clearly wrong

Liquid::Template.parse('{{ ((1..2)..3) }}') is another way to get that NoMethodError, by causing it to call .to_i on a Range object.

I'll open a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants