Skip to content

Logical operator order of operations differs from Ruby implementation #206

@ssolbeck

Description

@ssolbeck

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions