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

Logical operator order of operations differs from Ruby implementation #206

Open
ssolbeck opened this issue Sep 20, 2023 · 0 comments
Open

Comments

@ssolbeck
Copy link

The template below produces different results in this PHP implementation and in Shopify's Ruby implementation. Since this is a port of the Ruby implementation, I believe it should either have matching behavior, or include a clear warning of the difference.

{% if false and false or true %}
TRUE
{% else %}
FALSE
{% endif %}

Ruby:

FALSE

PHP:

TRUE

I think this is because Shopify/liquid evaluates logical operators right-to-left, as noted here: https://shopify.dev/docs/api/liquid/basics#order-of-operations
And from my read of the php-liquid implementation, it seems to evaluate them left-to-right. https://github.com/kalimatas/php-liquid/blob/master/src/Liquid/Tag/TagIf.php#L132-L142

Thank you!

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

No branches or pull requests

2 participants