-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Ordering of arguments changes the behaviour of binary expressions #566
Comments
Thanks for the repros. Note that your examples also show a related bug that needs to be fixed in Fluid, which is that comparison operators should return the compared value and not true/false when used in an output tag. Pretty sure I filed it (or at least I knew about it). For reference here are the results in Shopify (the source of truth) |
RE: "results in Shopify" How does it evaluate these? Does it return false for each, because I see in the Fluid.NET source code for LowerThanExpression.cs, that only types NumberValue and Nil are considered for comparison, else it returns Nil. In these "playgrounds", it returns what I would expect: true (I.e., that one should be able to do 'less than' etc. on Strings too.) P.S. I commented on this closed issue a few days ago, because I did not see this issue |
Use the blue boxes in this page: https://shopify.dev/docs/api/liquid#liquid_basics Nothing more to open, this issue already is, and I totally acknowledged the difference by showing the different result in Shopify. Feel free to start trying to fix it as I won't be able to in the short term. |
Thanks for the "playground" link. For completeness, in that link I tried: The results there are The results in Fluid.Net are RE: " more to open" |
Hey, @sebastienros apologies for the delayed follow up. Thanks for the confirmation and the Shopify playground link. I wasn't aware of the related bug where operators shouldn't return their result, but the left operand instead. That's is a bit odd, but good to know! 😃 Perhaps I can give a closer look, but no promises. 👍 |
Let's start with a minimal reproduction:
As a Liquid writer, I would expect
a == b
andb == a
to evaluate to the same boolean, but the above example shows that evaluated varies based on argument order. This is not only applicable to the equals binary expression either. For example, less than shows an identical discrepancy:Or a boolean example:
Contrast this with LiquidJS, where the outcome of these expressions is more sensible (https://liquidjs.com/playground.html#e3sgJzEyMycgPT0gMTIzIH19Cnt7IDEyMyA9PSAnMTIzJyB9fQp7eyAnMScgPCAyIH19Cnt7IDEgPCAnMicgfX0Ke3sgJ2hpJyA9PSB0cnVlIH19Cnt7IHRydWUgPT0gJ2hpJyB9fQo=,e30=):
It seems that runtime types are always respected first, but for numbers there's a dynamic conversion. I am not sure where the reference Shopify implementations stands.
The text was updated successfully, but these errors were encountered: