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

Globals and "or" compiler warning #225

Open
theindexer opened this issue Jan 25, 2021 · 0 comments
Open

Globals and "or" compiler warning #225

theindexer opened this issue Jan 25, 2021 · 0 comments

Comments

@theindexer
Copy link

When I try to do something like
{if GLOBAL == 'x' or GLOBAL == 'y' or GLOBAL== 'z'}
I get a bushel (4, in fact - G==x or G==y, G==x, G==y, G==z) of compiler warnings like

warning: Constant operand 'GLOBAL == 'x' or GLOBAL == 'y'' used with 'or' operator. Consider simplifying 
or using the ?: operator, see go/soy/reference/expressions.md#logical-operators  

This seems like a fine use of the or operator to me. Yeah the GLOBAL's constant, but I don't know what it's going to be when I'm writing the template. It's my understanding that this is trying to prevent things like {if $x or true} or {let $x: $y or 5} but this is neither of those. The only way out I see to appease the compiler warning is adding some ?: and parens in which seems...unpleasant.

Am I missing something or is this just unfortunate?

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

No branches or pull requests

1 participant